Post here is you are having problems with any of the tutorials.
jaymeh
Posts: 27 Joined: Wed Jan 04, 2012 12:42 pm
Location: West Yorkshire
Post
by jaymeh » Mon Jan 09, 2012 11:32 pm
Hi Temor,
I found one of our errors, the one on line 95 with the mysql, I was missing a ` after user_password.
My final issue now, at least I hope is the one of line 55 with the foreach() invalid arguement.
Although the valid credentials validation still isnt working correctly.
bowersbros
Posts: 534 Joined: Thu May 05, 2011 8:19 pm
Post
by bowersbros » Mon Jan 09, 2012 11:35 pm
do a print_r($errors)
and see what you get.
Post the output here
I don't like to brag, but I wasn't circumcised. I was circumnavigated.
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos:
http://goo.gl/58pN9
jaymeh
Posts: 27 Joined: Wed Jan 04, 2012 12:42 pm
Location: West Yorkshire
Post
by jaymeh » Mon Jan 09, 2012 11:58 pm
Hi, where do I put print_r($errors)
on the login page?
EDIT: I got Username/Password incorrect.
EDIT: Which is the same as what I got when I tried to create the userlogin system a second time.
Temor
Posts: 1186 Joined: Thu May 05, 2011 8:04 pm
Post
by Temor » Tue Jan 10, 2012 12:18 am
if (valid_credentials($_POST['username'], $_POST['password']) === false)
try removing one of the equals signs.
jaymeh
Posts: 27 Joined: Wed Jan 04, 2012 12:42 pm
Location: West Yorkshire
Post
by jaymeh » Tue Jan 10, 2012 12:31 am
Nope, still not working
. If i change it to true, it works but so does every other user/password combination. Which is strange. The information I'm typing in is also correct. I even tried creating the whole login system again today. I have hit exactly the same problem.
Temor
Posts: 1186 Joined: Thu May 05, 2011 8:04 pm
Post
by Temor » Tue Jan 10, 2012 12:59 am
jaymeh wrote: Nope, still not working
. If i change it to true, it works but so does every other user/password combination. Which is strange. The information I'm typing in is also correct. I even tried creating the whole login system again today. I have hit exactly the same problem.
Hmm... Do you get the username and password if you
print_r($_POST); ?
jaymeh
Posts: 27 Joined: Wed Jan 04, 2012 12:42 pm
Location: West Yorkshire
Post
by jaymeh » Tue Jan 10, 2012 1:35 am
Yeah, they both show up. Its almost like they cant talk to the database which weird.
Array ([username] => jaymeh [password] => jaymeh
Temor
Posts: 1186 Joined: Thu May 05, 2011 8:04 pm
Post
by Temor » Tue Jan 10, 2012 2:11 am
are you sure you're establishing a connection to the database then? If you are then I'm clueless.
jaymeh
Posts: 27 Joined: Wed Jan 04, 2012 12:42 pm
Location: West Yorkshire
Post
by jaymeh » Tue Jan 10, 2012 10:15 am
Ill check the user exists function to see if that works because it means that im making a connection that way.
EDIT: There must be a connection since other sql functions work within the project. :/ I have no idea whats wrong with it...
$user = mysql_real_escape_string($user);
$pass = sha1($pass);
$total = mysql_query("SELECT COUNT (`user_id`) FROM `users` WHERE `user_username` = '{$user}' AND `user_password` = '{$pass}'");
return (mysql_result($total, 0) == '1') ? true : false;
Temor
Posts: 1186 Joined: Thu May 05, 2011 8:04 pm
Post
by Temor » Tue Jan 10, 2012 1:41 pm
I know whats wrong
You set password max length to 32 characters in your table. Sha1 will always produce a 40 character string.
32 characters won't match with 40
up your length limit to 40, re-register and it should work just fine
jaymeh
Posts: 27 Joined: Wed Jan 04, 2012 12:42 pm
Location: West Yorkshire
Post
by jaymeh » Tue Jan 10, 2012 1:56 pm
Hi Temor,
Thanks again. But I have passwords in the database which I have used to test but these passwords still do not work, unless the peice of code is looking for a password with sha1 coding in which case, I feel very silly
.
Ill have a look and test that now
Thanks again
Jamie
jaymeh
Posts: 27 Joined: Wed Jan 04, 2012 12:42 pm
Location: West Yorkshire
Post
by jaymeh » Tue Jan 10, 2012 1:59 pm
Hi Temor,
Right now I feel so stupid, that worked a treat, I''d like to thank you for all your help over the past few days
Happy coding
Thank again
Jamie
Temor
Posts: 1186 Joined: Thu May 05, 2011 8:04 pm
Post
by Temor » Tue Jan 10, 2012 2:02 pm
I'm happy we solved it
Should not have taken this long though. I should have spotted that earlier
If you're ever in need of help, don't hesitate to post. I'm on here most of the time.