dean7 Posted October 22, 2009 Share Posted October 22, 2009 Hi all, on my website users need to login to veiw them members area but somthing is up with my script, it lets them login to the members area but dont show nothing, but on there stats page it says not loged in. Heres the code: <title>Great-Racing || Login</title> <?php include('css/style.css'); ?> <? oB_start(); // allows you to use cookies. include("config.php"); if (!$logged[username]) { if (!$_POST[login]) { echo(" <center><form method=\"POST\"> <br> <br> <table border=\"1px\" bordercolor=\"#000000\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#333333\"> <tr> <td> <img src=\"images/banner.jpg\"> </td> </tr> <tr> <td class='header'> <center><b><code>Register, Lost Password And TOS</code></center></b> </td> </tr> <tr> <td> <center>:: <a href='Register.php'>Register</a> :: || :: <a href='lostpass.php'>Lost Password</a> :: || :: <a href='tos.php'>TOS</a> :: </center> </td> </tr> <tr> <td class='header'> <center><b>Username:</center></b> </td> </tr> <tr> </td> <tr> <td align=\"center\"> <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"> </td> </tr> <tr> <td class='header'> <center><b>Password:</center></b> </td> </tr> <tr> <td align=\"center\"> <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\"> </td></tr><tr> <td align=\"center\"> <input type=\"submit\" name=\"login\" value=\"Login\"> </td></tr> <tr> <td class='header'> <center><b><code>Thanks For Playing!</center></b></code> </td> </tr> </table></form></center>"); } if ($_POST[login]) { // the form has been submitted. We continue... $username= mysql_real_escape_string($_POST['username']); $password = md5(mysql_real_escape_string($_POST[password])); // the above lines set variables with the submitted information. $info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die("MySQL Error " . mysql_error()); $data = mysql_fetch_array($info); if($data[password] != $password) { // the password was not the user's password! echo ("<center><table width='70%'border='1px' bordercolor='#000000'> <tr> <td bgcolor='#FF6600'> <center><b>Somthing Is Wrong</b></center> </td> </tr> <tr> <td> <center>You have either a incorrect <b>username</b> or <b>password</b>!</center> </td> </tr> </table>"); }else{ $timestamp = time()+60; mysql_query("UPDATE users SET online='$timestamp' WHERE username='$username'"); // the password was right! $query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die("MySQL Error " . mysql_error()); $user = mysql_fetch_array($query); // gets the user's information setcookie("id", $user[id],time()+(60*60*24*5), "/", ""); setcookie("pass", $user[password],time()+(60*60*24*5), "/", ""); // the above lines set 2 cookies. 1 with the user's id and another with his/her password. echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://**********.com/index2.php\"/>Thank You! You will be redirected"); //add in your site url } } } else { echo "<meta http-equiv=\"Refresh\" content=\"0; URL=http://***********.com/index2.php\"/>"; } ?> Anyone know why? Thanks. Link to comment https://forums.phpfreaks.com/topic/178572-login-help/ Share on other sites More sharing options...
Gayner Posted October 22, 2009 Share Posted October 22, 2009 Show us index2.php, lol. Link to comment https://forums.phpfreaks.com/topic/178572-login-help/#findComment-941735 Share on other sites More sharing options...
dean7 Posted October 22, 2009 Author Share Posted October 22, 2009 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <?php include('css/style.css'); include("makelogin.php"); include("functions.php"); session_start(); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <frameset rows="*" cols="150,*" frameborder="no" border="0" framespacing="0"> <frame src="nav.php" name="leftFrame" scrolling="Auto" noresize="noresize" id="leftFrame" /> <frameset rows="100,*" framespacing="0" frameborder="no" border="0" bordercolor="#000000"> <frame src="banner.php" name="topFrame" scrolling="Auto" noresize="noresize" id="topFrame" /> <frameset rows="30,*" height="45" framespacing="0" frameborer="no" border="0" boredercolor="#000000"> <frame src="stats.php" name="statsFrame" scrolling="No" noresize="noresize" id="statsFrame" /> <frame src="main.php" name="mainFrame" id="mainFrame" /> </frameset> </frameset> <noframes><body> </body> </noframes></html> Index2 file Link to comment https://forums.phpfreaks.com/topic/178572-login-help/#findComment-941753 Share on other sites More sharing options...
cags Posted October 22, 2009 Share Posted October 22, 2009 Looking at your first set of code I see quite a few potential issues with it. a.) You have a short_open tag, which will cause problems on certain servers. b.) With this... $_POST[login] ...piece of code I assume login is not a constant and is a key in the $_POST array, meaning it should be a string... $_POST['login']. The same rule applies in at least half a dozen other places. They shouldn't stop the code working, but will throw notices. c.) Same as above applies to... $logged[username] ... with the added question of where is the $logged array declared? Link to comment https://forums.phpfreaks.com/topic/178572-login-help/#findComment-941853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.