ataria Posted October 3, 2006 Share Posted October 3, 2006 I get no errors, but, when it goes to sign you in it takes you to 'login.php?action=Login' (like it's supposed to, but, it shows the log in script again...here is the code.please help! [code]<?phpinclude ("global.php");if ( $_POST['action'] == "Login" ){ $get_user = @mysql_query( "SELECT * FROM `users` WHERE `username` LIKE '" . strip( $_POST['username'] ) . "'" ); $count_user = @mysql_num_rows( $get_user ); $user = @mysql_fetch_array( $get_user ); $enc_pass = ( $_POST['password'] ); if ( empty( $_POST['username'] ) ) { echo ( success( "You forgot to enter a username.", "Error" ) ); } elseif ( empty( $_POST['password'] ) ) { echo ( success( "You forgot to enter your password.", "Error" ) ); } elseif ( $count_user == 0 ) { echo ( success( "The username you entered does't exist.", "Error" ) ); } elseif ( $enc_pass != $user['password'] ) { echo ( success( "Passwords don't match, try again.", "Error" ) ); } else { setcookie( "uid", $user['uid'], time() + 31536000, "/" ); echo ( success( "You are now logged in... Have fun :) $update", "Success" ) ); $update = @mysql_query( "UPDATE `users` SET `login`='$day' WHERE `uid`='{$user['uid']}'" ); } }else {echo"<center>";echo"<br />";echo"<form method='post' action=login.php?action=Login>";echo"<table border='0' cellspacing='0' class='border' width='500'>";echo"<tr>";echo"<td align='center' colspan='2'>Login</td>";echo"</tr>";echo"<tr>";echo"<td align='center'><strong>Username:</strong></td>";echo"<td align='left'><input type='text' name='username'></td>";echo"</tr>";echo"<tr>";echo"<td align='center'><strong>Password:</strong></td>";echo"<td align='left'><input type='password' name='password'></td>";echo"</tr>";echo"<tr>";echo"<td align='center' colspan='2'><input type='submit' value='Login'></td>";echo"</tr>";echo"</table>";echo"</form></center>";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/22918-login-i-need-help/ Share on other sites More sharing options...
JayBachatero Posted October 3, 2006 Share Posted October 3, 2006 Well you are not redirecting the user to any location. Use header('Location: http://...'); Link to comment https://forums.phpfreaks.com/topic/22918-login-i-need-help/#findComment-103365 Share on other sites More sharing options...
ataria Posted October 3, 2006 Author Share Posted October 3, 2006 Where would I use that? Link to comment https://forums.phpfreaks.com/topic/22918-login-i-need-help/#findComment-103371 Share on other sites More sharing options...
alpine Posted October 3, 2006 Share Posted October 3, 2006 That's not your primary problem here,Change --> [color=red]if ( $_POST['action'] == "Login" )[/color]to --> [color=blue]if ( $_GET['action'] == "Login" )[/color]for it to work as you intended in this script (POST to GET on THAT variable)Still it would be better to name the submit button e.g. "submit" and then sniff for --> if(isset($_POST['submit']))....then removing the get variable in your form action....Just a point of view though.. Link to comment https://forums.phpfreaks.com/topic/22918-login-i-need-help/#findComment-103405 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.