The Saint Posted August 4, 2007 Share Posted August 4, 2007 It works now, but when i login it takes me to the Incorrect.php and its correct and does anyone have any basic incorrect.php and main.php sources please help me out Quote Link to comment https://forums.phpfreaks.com/topic/63343-solved-login-now-hafly-working/ Share on other sites More sharing options...
The Saint Posted August 4, 2007 Author Share Posted August 4, 2007 DO_Login.php <?php $connection = mysql_connect(localhost , root, ""); $db = mysql_select_db(user, $connection); $sql = "SELECT id FROM users WHERE username='$_POST[username]' AND password='$_POST[password]'"; $result = mysql_query($sql) or die(mysql_error()); $num = mysql_num_rows($result); if ($num > 0) { //USER AND PASS ARE CORRECT $id = mysql_fetch_assoc($result); setcookie("auth", "yes", time()+3600); setcookie("id", $id['id']); setcookie("username", $id['username']); header ("Location: main.php"); }else { header ("Location: incorrect.php"); }; ?> Login.PHP <body background="blue.jpg"> <font face="arial"> <form name=login action=do_login.php method=post> <table border=0 cellspacing=0 cellpadding=2> <tr><td> <font face="sans-serif"><font color="black">Username:</font></b></font></font><td><input type=text name=username> <tr><td> <font face="sans-serif"><font color="black">Password:</font></b></font></font><td><input type=password name=password> <tr><td colspan=2 align=left><img src="blue.jpg"height="2" width="70"><input type="checkbox" name="remember"> <font size="2"><font face="sans-serif"><font color="black">Remember Me</font></b></font></font><img src="blue.jpg"height="2" width="93"><input type=submit value='Login!'><form method="GET" action="refreshbutton.htm" align=right><input type="button" onclick="refresh()" value="Reset" name="button1"> </table> </form> </body> </html> <html> <head> <script language="JavaScript"> --> <!-- /. var sURL = unescape(window.location.pathname); function refresh() { window.location.href = sURL; } //--> </script> <script language="JavaScript1.1"> <!-- function refresh() { window.location.replace( sURL ); } //--> </script> <script language="JavaScript1.2"> <!-- function refresh() { window.location.reload( false ); } //--> </script> </head> <body> <!-- </form> </body> </html> Incorrecy.php <body background="blue.jpg"> blank because i dont have a source as to MAIN.php Quote Link to comment https://forums.phpfreaks.com/topic/63343-solved-login-now-hafly-working/#findComment-315646 Share on other sites More sharing options...
The Saint Posted August 4, 2007 Author Share Posted August 4, 2007 can anyone help! Quote Link to comment https://forums.phpfreaks.com/topic/63343-solved-login-now-hafly-working/#findComment-315667 Share on other sites More sharing options...
Barand Posted August 4, 2007 Share Posted August 4, 2007 If the login is incorrect I'd send them back to the login and show an error message something like "Incorrect username or password" }else { header ("Location: login.php?error=y"); } And in login.php <?php if (isset($_GET['error']) && $_GET['error']=='y') echo "Incorrect username or password"; // login form here Quote Link to comment https://forums.phpfreaks.com/topic/63343-solved-login-now-hafly-working/#findComment-315674 Share on other sites More sharing options...
pyrodude Posted August 4, 2007 Share Posted August 4, 2007 If it's directing to the wrong place, there's probably an issue with your query. Try commenting out the redirects and echo your $sql and $num and see where the issue lies Quote Link to comment https://forums.phpfreaks.com/topic/63343-solved-login-now-hafly-working/#findComment-315681 Share on other sites More sharing options...
The Saint Posted August 4, 2007 Author Share Posted August 4, 2007 <font face="arial"> <body background="blue.jpg"> <?php if (isset($_GET['error']) && $_GET['error']=='y') echo "Incorrect username or password"; // <form name=login action=do_login.php method=post> <table border=0 cellspacing=0 cellpadding=2> <tr><td> <font face="sans-serif"><font color="black">Username:</font></b></font></font><td><input type=text name=username> <tr><td> <font face="sans-serif"><font color="black">Password:</font></b></font></font><td><input type=password name=password> <tr><td colspan=2 align=left><img src="blue.jpg"height="2" width="70"><input type="checkbox" name="remember"> <font size="2"><font face="sans-serif"><font color="black">Remember Me</font></b></font></font><img src="blue.jpg"height="2" width="93"><input type=submit value='Login!'><form method="GET" action="refreshbutton.htm" align=right><input type="button" onclick="refresh()" value="Reset" name="button1"> </table> </form> </body> </html> <html> <head> <script language="JavaScript"> --> <!-- /. var sURL = unescape(window.location.pathname); function refresh() { window.location.href = sURL; } --> </script> <script language="JavaScript1.1"> <!-- function refresh() { window.location.replace( sURL ); } --> </script> <script language="JavaScript1.2"> <!-- function refresh() { window.location.reload( false ); } //--> </script> </head> <body> <!-- </form> </body> </html> Erorr:Parse error: syntax error, unexpected '<' in C:\wamp2\www\Saintsprojects\login.php on line 8 Quote Link to comment https://forums.phpfreaks.com/topic/63343-solved-login-now-hafly-working/#findComment-315693 Share on other sites More sharing options...
pyrodude Posted August 4, 2007 Share Posted August 4, 2007 Add a ?> after the if statement (line 7) Quote Link to comment https://forums.phpfreaks.com/topic/63343-solved-login-now-hafly-working/#findComment-315711 Share on other sites More sharing options...
The Saint Posted August 4, 2007 Author Share Posted August 4, 2007 I GOT IT TO WORK TURNS OUT THE PASS WAS WRONG SOMEHOW! WELL NOW THAT ITS TAKING ME TO MAIN.PHP HOW WILL I GET IT TO SAY HELLO, "USERNAME WHO JUST LOGGED IN HERE" on my website anyone got a script? Quote Link to comment https://forums.phpfreaks.com/topic/63343-solved-login-now-hafly-working/#findComment-315755 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.