If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

I might have another question real soon though because I'm having issues logging in. I think it might be something to do with matching the hashed passwords when comparing the input and the database values.

I wanted to achieve what sessions can do but with global variables...I got mixed up with the use of the static keyword not so long ago as well. I must remember they are to do with functions and not to hold data/use data between pages...

Thank you for all your help...I would attempt to start sorting out my login.php but it's too late to be doing that now. I'll end up coding even worse than I do already...

The issue was weird though because I remember trying to login locally, and it worked. So I uploaded it to the domain and tried the exact same thing and it didn't work...

When using global variables, if I have a script and it 'requires' another file, when I go into that file and set a global variable and that script ends and returns to the first script, does my global variable still exist until the end of execution, or does it die when it leaves the script which created it?

P.s - so annoyed, I tried hoovering my keys and ended up pulling off my right bracket and ENTER keys ...proving hard to fix.

Global vars are valid in the function that they are declared in. If the variable is in the top level of the script and you declare it a global in the function then it will still exist in the top level when you come back out of the function - see my previous example of globals.

As for the keyboard, if you have an ASDA near you they used to sell wired keyboards for £4. Not sure if they still do anymore, mine doesn't but still does the mice but their basic KB is now £7 iirc. Every store seems to vary though. I wouldn't bother with Tesco.. and I don't think Morrisons sell tech bits at all. I don't think Sainsburys sell anything useful unless its one of their larger stores.

I've only just been able to get on. I'll give global variables a read. I am not using globals with any functions, just setting a variable in a script to be global and it seems to be working.

I go into my do_reg action script. Then, I go into a reg_select.php script to check whether the username or email address is already registered at the site. Depending on what affected_rows returns I set a global variable and set it to TRUE if it matched a row and FALSE if not. I then leave that script and do an if statement in the calling script: if (global declared was set to true) display error, else (if no match was found, login) and it works. I'll re-run through the topic.

As for the keyboard, I've managed to fix it! Weren't as tricky as I first thought.

Well, I decided to forget setting globals and to set the session/ print error inside the prepared statement file.

I have been thoroughly through both my registration files and login files. I sat down and wrote the logic of both files and what happens and when. I really cannot see what could be the issue. The logic is pretty much the same and I do the same thing regarding the password and selecting the hash string from db etc.

if(mail($to,$subject,$message, implode("\r\n",$headers))){
echo "You have successfully registered! You will be contacted shortly with your login details.<br />";
echo "Please follow the <a href='login.php'>link</a> to the login page.";
exit(0);
}
else{
echo "You have successfully registered but there was an error sending your email.<br />";
echo "You are still able to login. Please contact the site administrator at flipmodeskwaud@hotmail.co.uk to report the problem.<br />";
echo "Follow the link to the <a href='login.php'>login</a> page.";
exit(0);
}
}
else{
echo "There was an internal error with your registration.<br />";
echo "Please contact the administrator at flipmodeskwaud@hotmail.co.uk and include the error shown. Thank you.<br />";
echo "Click <a href='index.php'>here</a> to go to the homepage.";
exit(0);
}

I think you're going to need to debug this to see what is happening in each script. It's easy to get omething workong on a localhost wamp system but coding it to work on a variety of systems really does take skill!

I can debug this for you via teamviewer / vnc however as this would take a while I'd have to be paid for it. My advice here on CF is always free as its just advice and theoretical stuff but actually spending what could be several hours on someones code is time consumning hence payment. I appreciate you'd probably like to avoid this option but the offer is there as a last resort.

In the meantime, if you can provide us with more information as to what is going on, I'll still try to help here.

What I mean is I can register and login fine when it's on localhost. When I upload it, it still lets me register and everything goes into the database fine, but when trying to login it executes this part of code:

If you look in my login_select.php this is my else statement to the if which checks the number of 'affected_rows'. I'm not sure why there are no affected_rows, I have also tried num_rows and it still doesn't work. The passwords both get concatenated with the random string and sent to the sha1() function before being used in any query... and the username matches fine because in my do_login script, I check if the user input matches a username.

I also took a note of the mysql and php versions which my domain is using:

PHP version: 5.3.14

MySQL version: 5.5.10

I also noticed it has magic quotes and magic quotes gpc turned on. They sound familiar i'll have a read into them. Not sure if they could be a possible issue?