Given the information that you've given me, that would be the only logical cause for that if else section of code.
The only other problem could be the query itself - eg if the DB table structure is not the same as it was on your localhost.
Try running the query in your hosts phpmyadmin SQL page and see that it works there first of all. If it does then its your script. If it doesn't then its a difference between systems - either mysql versions OR your DB structures.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
It looks like it yes. You might want to use mysqli_stmt_error after your execute to see if there is an error somewhere.
I don't personally use mysqli I use the old fashioned mysql so I'm kind of guessing here but you should always look for the error function and see if it returns anything.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
after execution, after storing the results and after fetching the results. It is returning no error to me....I attempted making a similar site a while ago and could register and login perfectly. The only difference with this site is the password hashing and the use of prepared statements. In my login_select.php which is used to check the username and password, I actually echo out the value of the hashed password, after it has been combined with the retrieved salt string from the database and even they match up ok.
I don't understand what could be going wrong....
Sorry to persist, but is there anything else at all that I could take a look at?
To be honest I'm running out of ideas here so it looks like i may have to abandon ship here and hope someone else can see the wood for the trees.
My offer of a debug still remains open (no fix, no fee though I've yet to be beaten) but to be frank, I'm running out of guesses that i can supply. I'm also certain that you're more than capable of debugging it and theorising whats going on!
Whatever is causing the query problem, your either getting no results or more than one result returned.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
Well it seems nowadays you're the only one who replies to me so I might have to seek a bit of advice from another forum or something because my last 2-3 threads are replied to only by yourself, no one else helps me lol.
Thanks dude appreciate the help though.
I'd take you up on your offer of a debug but what's the point when I am trying to learn PHP :P , I won't get better if I don't do it myself. Of course, your help has nearly always produced a result for me so of course a lot of credit goes to yourself and other people here.
I thought to myself, right open all scripts to do with the registration. I got my notepad out and wrote down step by step what is happening in my reg scripts and when. I also did the same for both of my login scripts and apart from minor differences such as query's and obviously in my reg scripts, the hash string is generated, combined with the pass and stored in the database along with the hashed password, where as in the login, the hash string retrieved from the database, combined with the users pass and then queried against the user's existing password field.
Thanks again for the help up to now, just unfortunate your ideas didn't resolve the issue this time. I'll keep a note of what you asked me to look for in case I have similar issues in the future.
Edit: Just printed $stmt with print_r() just after execution and it returned affected_rows as -1. php.net states it means the query returned an error but errno = 0 and error = empty string.
I printed that out after every statement issued to $stmt and it returned no errors until right after execution...
Post the code for the affected file again with your debugging print_r's in it please.
Also while I doubt this will work (like I said, I don't use mysqli - I really should but i'm too lazy) try wrapping the ? in your sql in ' marks like this: '?'
It shouldn't make any difference from what I see of the php manual but might just be worth a try.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
I tried adding the single quotations around the question marks but it returned this error to me:
Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters in prepared statement
I'm not sure what else to check. I know I am matching the correct hash string from the database because when I send the $_POST['password'] and the retrieved hash string and send them both to the sha1() function like I did in the registration script, it produces the correct password...
Edit:Just ran the same print_r($stmt) code through my localhost and it is also returning affected_rows -1 but it lets me login....
Does this mean it could potentially be a different issue? Can you narrow it down given this information?
None of this is making any sense. On your localhost you must be getting 1 for it to let you login yet you say its -1 like your main host. Very strange..
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.