|
|
|
|
![]() ![]() |
Mar 17 2005, 02:10 AM
Post
#1
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 629 Joined: 26-February 05 Member No.: 3,995 |
I don't know what's going wrong here, but it's probably a typo:
CODE $iusername = $_POST['username']; That's not all of it, but the rest is just to check if they hit login or were logged in successfully.
$ipassword = stripslashes($_POST['password']); include "opendatabase.php"; opendatabase(); $userrow = mysql_query("SELECT * FROM `users` WHERE `username`='$iusername' LIMIT 1;"); $userarr = mysql_fetch_array($userrow); $ipassword = md5($ipassword); if($ipassword != $userarr[3]) { echo "<div class=\"err\">Error: Incorrect username/password combination.</div>"; exit("</BODY></HTML>"); } mysql_close(); |
|
|
|
Mar 17 2005, 03:30 AM
Post
#2
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 661 Joined: 10-January 05 Member No.: 3,189 |
i think your include function should be like this
CODE include ("filename.php"); otherwise, i don't really see any error. |
|
|
|
Mar 17 2005, 03:33 AM
Post
#3
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 372 Joined: 14-October 04 Member No.: 1,736 |
No, the include function works that way as well. I use it like that all the time, and haven't gotten a single error. I don't see any errors in that code, either. It could possibly be a problem in the rest of the file, I'm not sure, though.
|
|
|
|
Mar 17 2005, 09:07 AM
Post
#4
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 113 Joined: 14-January 05 From: Philippines Member No.: 3,271 |
are you sure that the index you used for $userarr is correct? why don't you just fetch the row as an associative array. in that way you can access the index as the name of the column rather than as a number.
|
|
|
|
Mar 17 2005, 01:41 PM
Post
#5
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: Members Posts: 46 Joined: 10-March 05 Member No.: 4,343 |
Add "echo"s.
CODE $iusername = $_POST['username']; $ipassword = stripslashes($_POST['password']); include "opendatabase.php"; opendatabase(); $userrow = mysql_query("SELECT * FROM `users` WHERE `username`='$iusername' LIMIT 1;"); $userarr = mysql_fetch_array($userrow); $ipassword = md5($ipassword); // ----------- echo "$ipassword - $userarr[3]"; // ----------- if($ipassword != $userarr[3]) { echo "<div class=\"err\">Error: Incorrect username/password combination.</div>"; exit("</BODY></HTML>"); } mysql_close(); I always use "echo"-s for debuging... |
|
|
|
Mar 18 2005, 12:41 AM
Post
#6
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 629 Joined: 26-February 05 Member No.: 3,995 |
Finally figured it out, it was a combination of things. First, when I originally had it as an associative array, I used the right column but forgot to have stripslashes. Then, I used a numeric array I forgot that it starts at 0 and used the actual column number instead of what it should've been in the array. Thanks for the echo idea, haron.
Unfortunately, it still doesn't work. At the end, I have it to set the variable $loggedin to 1, then at the top I have it check if $loggedin is 1, and if it is to start the session. I don't think it's doing anything, though. I'd use cookies, but I don't know how to set it to die when the browser is closed, and cookies also have to be at the top. |
|
|
|
Mar 18 2005, 12:50 AM
Post
#7
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 372 Joined: 14-October 04 Member No.: 1,736 |
Well, I've never really gotten the hang of cookies, but to set it so that it will expire when the browser closes, you just don't add an expiration date to the cookie, then it'll close as soon as the browser is closed. Hey, at least you fixed some of the problems with it.
|
|
|
|
Mar 18 2005, 01:02 AM
Post
#8
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 629 Joined: 26-February 05 Member No.: 3,995 |
I looked at what I had on my school's server, and realized that it works if you just put all the code at the top instead of making it jump around. Now I just have to make something that only members can see =P
|
|
|
|
Mar 18 2005, 04:46 AM
Post
#9
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 113 Joined: 14-January 05 From: Philippines Member No.: 3,271 |
QUOTE(beeseven @ Mar 18 2005, 09:02 AM) I looked at what I had on my school's server, and realized that it works if you just put all the code at the top instead of making it jump around. Now I just have to make something that only members can see =P now that you have something to show, how about handling your sessions? have you done it already? if you are not into cookies, for sure you will not have the "remember me" stuff. i suggest make a session class that will support those who still uses cookies so that you can remember them. as well as those who fear cookies. |
|
|
|