grlayouts Posted November 25, 2009 Share Posted November 25, 2009 Okay I have a login and every time someone tries to use it they get the error "Please fill out all fields." the code i have is <?php print"<form method=post action=login.php> <td width=100% align=center> <center><table > <tr align=center><td> Username </tD><td> Password </td><tr align=center> <tD> <input type=text name=user size=17 class=dashb> </tD><tD> <input type=password name=pass size=17 class=dashb> </tD></tr> </table> </td></tR><tR> <td> <center> <input type=submit value=Login>"; ?> and for the login.php <?php if (!$user || !$pass) { include("headernologin.php"); print "Please fill out all fields."; exit; } include("headernologin.php"); $logres = mysql_num_rows(mysql_query("select * from players where user='$user' and pass='$pass'")); $stat = mysql_fetch_array(mysql_query("select * from players where user='$user' and pass='$pass'")); if ($logres <= 0) { print "Login failed. If you have not already, please signup. Otherwise, check your spelling and login again."; exit; } else { session_register("user"); session_register("pass"); } $ip = " $_SERVER[REMOTE_ADDR] "; mysql_query("update players set ip='$ip' where id=$stat[id]"); print"<br><center>You are being logged at IP $ip"; ?> the header file only have the database connect. any idea's why it keeps saying that? Link to comment https://forums.phpfreaks.com/topic/182935-login-error/ Share on other sites More sharing options...
mrMarcus Posted November 25, 2009 Share Posted November 25, 2009 it's a register_globals issue. the server you're using has register_globals turned off. which means, that instead of: if (!$user || !$pass) { you need: if (!$_POST['user'] || !$_POST['pass']) { and while you're at it, change this: session_register("user"); session_register("pass"); to: $_SESSION['user']; $_SESSION['pass'] = $_POST['pass']; matter of fact, here: <?php if (!isset ($_POST['user']) || (!isset ($_POST['pass']))) { include("headernologin.php"); print "Please fill out all fields."; exit; } else { session_start(); include("headernologin.php"); $user = mysql_real_escape_string ($_POST['user']); $pass = mysql_real_escape_string ($_POST['pass']); $logres = mysql_num_rows(mysql_query("select * from players where user='$user' and pass='$pass'")); $stat = mysql_fetch_array(mysql_query("select * from players where user='$user' and pass='$pass'")); if ($logres <= 0) { print "Login failed. If you have not already, please signup. Otherwise, check your spelling and login again."; exit; } else { $_SESSION['user'] = $user; $_SESSION['pass'] = $pass; } $ip = $_SERVER['REMOTE_ADDR']; mysql_query("update players set ip='$ip' where id=$stat[id]"); print"<br><center>You are being logged at IP $ip"; } ?> Link to comment https://forums.phpfreaks.com/topic/182935-login-error/#findComment-965577 Share on other sites More sharing options...
grlayouts Posted November 25, 2009 Author Share Posted November 25, 2009 thank you so much.. =) Link to comment https://forums.phpfreaks.com/topic/182935-login-error/#findComment-965578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.