searls03 Posted December 12, 2011 Share Posted December 12, 2011 I am having a problem with sessions loading on my site: troop78.bammz.net. when I login it to login again, but if i type a wrong username, then there is an error telling me to try again, not the message I get when a session expires. I had this working on another server, but then I had to switch to a new one. I asked and they said sessions should be working fine. if you can offer any help, please do. <?php /* Created By Adam Khoury @ [url='http://www.flashbuilding.com/']www.flashbuilding.com[/url] -----------------------June 20, 2008----------------------- */ session_start(); if ($_POST['username']) { //Connect to the database through our include include_once "secure/connect_to_mysql_1.php"; $username = stripslashes($_POST['username']); $username = strip_tags($username); $username = mysql_real_escape_string($username); $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters $password = md5($password); // Make query and then register all database data that - // cannot be changed by member into SESSION variables. // Data that you want member to be able to change - // should never be set into a SESSION variable. $sql = mysql_query("SELECT * FROM sessions WHERE username='".$username."' AND password='".$password."'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ // Get member ID into a session variable $id = $row["id"]; session_register('id'); $_SESSION['id'] = $id; // Get member username into a session variable $name = $row["name"]; session_register('name'); $_SESSION['username'] = $username; // Get member userlevel into a session variable $userlevel = $row["userlevel"]; session_register('userlevel'); $_SESSION['userlevel'] = 9; // Update last_log_date field for this member now mysql_query("UPDATE sessions SET lastlogin=now() WHERE id='".$id."'"); // Print success message here if all went well then exit the script $errorMsg = ''; $pass = ''; $remember = ''; if (isset($_POST['Submit'])) { $pass = $_POST['password']; if (isset($_POST['remember'])) { $remember = $_POST['remember']; } $pass = stripslashes($pass); $pass = strip_tags($pass); if($remember == "yes"){ $encryptedID = base64_encode("g4enm2c0c4y3dn3727553".$id); setcookie("idCookie", $encryptedID, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days setcookie("passCookie", $password, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days } // All good they are logged in, send them to homepage then exit script header("location: secure/selector.php"); exit(); }} // close while } else { // Print login failure message to the user and link them back to your login page print '<br /><br /><font color="#FF0000">Sorry, incorrect username or password, please try again! </font><br />'; }} ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Login</title> <style type="text/css"> #editregion { position:relative; left:-2px; top:260px; width:1293px; height:51px; z-index:1; text-align: center; clear: none; float: none; } body { background-image: url(button/boyscout1.png); background-repeat: no-repeat; position: relative; } #menu #MenuBar1 li a { color: #000; border-top-style: outset; border-right-style: outset; border-bottom-style: outset; border-left-style: outset; position: relative; cursor: default; filter: Invert; page-break-after: always; width: 100px; } #menu { position:absolute; left:63px; top:177px; width:273px; height:59px; z-index:19; } #status { position:absolute; left:16px; top:180px; width:124px; height:44px; z-index:14; } </style> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } </script> <style type="text/css"> #editregion { position:relative; left:-2px; top:260px; width:1293px; height:51px; z-index:1; text-align: center; clear: none; float: none; } body { background-image: url(button/boyscout1.png); background-repeat: no-repeat; position: relative; } #menu #MenuBar1 li a { color: #000; border-top-style: outset; border-right-style: outset; border-bottom-style: outset; border-left-style: outset; position: relative; cursor: default; filter: Invert; page-break-after: always; width: 100px; } #menu { position:absolute; left:63px; top:165px; width:273px; height:59px; z-index:19; } #status { position:absolute; left:16px; top:180px; width:124px; height:44px; z-index:14; } </style> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } </script> <style type="text/css"> #apDiv1 { position:absolute; left:33px; top:203px; width:252px; height:48px; z-index:1; } #apDiv2 { position:absolute; left:33px; top:244px; width:254px; height:80px; z-index:2; } #apDiv3 { position:absolute; left:33px; top:367px; width:256px; height:65px; z-index:3; } #apDiv4 { position:absolute; left:33px; top:285px; width:250px; height:61px; z-index:4; } #apDiv5 { position:absolute; left:339px; top:199px; width:263px; height:255px; z-index:5; } #apDiv6 { position:relative; left:-2px; top:260px; width:1293px; height:51px; z-index:1; text-align: center; clear: none; float: none; } #apDiv7 { position:absolute; left:33px; top:326px; width:266px; height:83px; z-index:6; } body { background-image: url(secure/button/boyscout1.png); background-repeat: no-repeat; } </style> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } </script> <style type="text/css"> #logout { position:absolute; left:1099px; top:186px; width:134px; height:38px; z-index:20; font-weight: bold; font-size: 24px; } #logout a { color: #000; } #footer { position:absolute; left:98px; top:512px; width:239px; height:70px; z-index:21; clear: both; float: none; } #status { text-align: center; } </style> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <style type="text/css"> #logout { position:absolute; left:1099px; top:186px; width:134px; height:38px; z-index:20; font-weight: bold; font-size: 24px; } #logout a { color: #000; } #footer { position:absolute; left:98px; top:512px; width:239px; height:70px; z-index:21; clear: both; float: none; } #status { text-align: center; } </style> </head> <body> <div id="apDiv6"> <script type="text/javascript"> <!-- Form Validation --> function validate_form ( ) { valid = true; if ( document.logform.username.value == "" ) { alert ( "Please enter your User Name" ); valid = false; } if ( document.logform.pass.value == "" ) { alert ( "Please enter your password" ); valid = false; } return valid; } <!-- Form Validation --> </script> <div align="center"> <h3><br /> <br /> Log in to your account here<br /> <br /> </h3> </div> <table align="center" cellpadding="5"> <form action="login.php" method="post" enctype="multipart/form-data" name="logform" id="logform" onsubmit="return validate_form ( );"> <tr> <td class="style7"><div align="right">Username:</div></td> <td><input name="username" type="text" id="username" size="30" maxlength="64" /></td> </tr> <tr> <td class="style7"><div align="right">Password:</div></td> <td><input name="password" type="password" id="password" size="30" maxlength="24" /><input type="hidden" name="remember" value="yes" /></td> </tr> <tr> <td> </td> <td><input name="Submit" type="submit" value="Login" /></td> </tr> </form> </table> <br /> </p> </div> <div id="menu"> <ul id="MenuBar1" class="MenuBarHorizontal"> <li><a href="pictures.php">Pictures</a> </li> <li><a href="login.php">Login</a></li> </ul> </div> <script type="text/javascript"> var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"}); </script> </body> </html> Quote Link to comment Share on other sites More sharing options...
Andy-H Posted December 12, 2011 Share Posted December 12, 2011 You must have been running an old version of PHP because session_register had been depreciated since PHP 5.3 and there has been a warning against using it on php.net for a long time. Change all occurrences of session_register('key'); to $_SESSION['key'] = $value; And session_is_registered('key'); to isset($_SESSION['key']); Quote Link to comment Share on other sites More sharing options...
searls03 Posted December 12, 2011 Author Share Posted December 12, 2011 that is how it was set up. even at that I went back and did it again and still nothing. Quote Link to comment Share on other sites More sharing options...
Andy-H Posted December 12, 2011 Share Posted December 12, 2011 What happens if you put ini_set('display_errors', 'On'); error_reporting(E_ALL); At the top of the script? Quote Link to comment Share on other sites More sharing options...
searls03 Posted December 12, 2011 Author Share Posted December 12, 2011 I get Notice: Undefined index: name in /home/searls04/public_html/login.php on line 29 Notice: Undefined index: userlevel in /home/searls04/public_html/login.php on line 33 Warning: Cannot modify header information - headers already sent by (output started at /home/searls04/public_html/login.php:29) in /home/searls04/public_html/login.php on line 40 Quote Link to comment Share on other sites More sharing options...
Andy-H Posted December 12, 2011 Share Posted December 12, 2011 Ok, lines 29 + 33 are session_register('name'); //and session_register('userlevel'); Which you need to remove as I said before. The other is from you header location (there is something being outputted before it), do you have any spaces or anything before your PHP opening tag? Quote Link to comment Share on other sites More sharing options...
searls03 Posted December 12, 2011 Author Share Posted December 12, 2011 I got rid of the errors, saying because I didn't have them in the database.....but I do get the same error except on login.php it says undefined index: submit; on line 8 Quote Link to comment Share on other sites More sharing options...
searls03 Posted December 12, 2011 Author Share Posted December 12, 2011 here is updated code: still doesn't work <?php ini_set('display_errors', 'On'); error_reporting(E_ALL); /* Created By Adam Khoury @ [url='http://www.flashbuilding.com/']www.flashbuilding.com[/url] -----------------------June 20, 2008----------------------- */ if ($_POST['Submit']) { //Connect to the database through our include include_once "secure/connect_to_mysql_1.php"; $username = stripslashes($_POST['username']); $username = strip_tags($username); $username = mysql_real_escape_string($username); $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters $password = md5($password); // Make query and then register all database data that - // cannot be changed by member into SESSION variables. // Data that you want member to be able to change - // should never be set into a SESSION variable. $sql = mysql_query("SELECT * FROM sessions WHERE username='$username' AND password='$password'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ // Get member ID into a session variable $id = $row["id"]; $_SESSION['id'] = $id; // Get member username into a session variable // Update last_log_date field for this member now mysql_query("UPDATE sessions SET lastlogin=now() WHERE id='$id'"); // Print success message here if all went well then exit the script header("location: secure/selector.php"); exit(); // close while }} else { // Print login failure message to the user and link them back to your login page print '<br /><br /><font color="#FF0000">Sorry, incorrect username or password, please try again! </font><br />'; }} ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Login</title> <style type="text/css"> #editregion { position:relative; left:-2px; top:260px; width:1293px; height:51px; z-index:1; text-align: center; clear: none; float: none; } body { background-image: url(button/boyscout1.png); background-repeat: no-repeat; position: relative; } #menu #MenuBar1 li a { color: #000; border-top-style: outset; border-right-style: outset; border-bottom-style: outset; border-left-style: outset; position: relative; cursor: default; filter: Invert; page-break-after: always; width: 100px; } #menu { position:absolute; left:63px; top:177px; width:273px; height:59px; z-index:19; } #status { position:absolute; left:16px; top:180px; width:124px; height:44px; z-index:14; } </style> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } </script> <style type="text/css"> #editregion { position:relative; left:-2px; top:260px; width:1293px; height:51px; z-index:1; text-align: center; clear: none; float: none; } body { background-image: url(button/boyscout1.png); background-repeat: no-repeat; position: relative; } #menu #MenuBar1 li a { color: #000; border-top-style: outset; border-right-style: outset; border-bottom-style: outset; border-left-style: outset; position: relative; cursor: default; filter: Invert; page-break-after: always; width: 100px; } #menu { position:absolute; left:63px; top:165px; width:273px; height:59px; z-index:19; } #status { position:absolute; left:16px; top:180px; width:124px; height:44px; z-index:14; } </style> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } </script> <style type="text/css"> #apDiv1 { position:absolute; left:33px; top:203px; width:252px; height:48px; z-index:1; } #apDiv2 { position:absolute; left:33px; top:244px; width:254px; height:80px; z-index:2; } #apDiv3 { position:absolute; left:33px; top:367px; width:256px; height:65px; z-index:3; } #apDiv4 { position:absolute; left:33px; top:285px; width:250px; height:61px; z-index:4; } #apDiv5 { position:absolute; left:339px; top:199px; width:263px; height:255px; z-index:5; } #apDiv6 { position:relative; left:-2px; top:260px; width:1293px; height:51px; z-index:1; text-align: center; clear: none; float: none; } #apDiv7 { position:absolute; left:33px; top:326px; width:266px; height:83px; z-index:6; } body { background-image: url(secure/button/boyscout1.png); background-repeat: no-repeat; } </style> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } </script> <style type="text/css"> #logout { position:absolute; left:1099px; top:186px; width:134px; height:38px; z-index:20; font-weight: bold; font-size: 24px; } #logout a { color: #000; } #footer { position:absolute; left:98px; top:512px; width:239px; height:70px; z-index:21; clear: both; float: none; } #status { text-align: center; } </style> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <style type="text/css"> #logout { position:absolute; left:1099px; top:186px; width:134px; height:38px; z-index:20; font-weight: bold; font-size: 24px; } #logout a { color: #000; } #footer { position:absolute; left:98px; top:512px; width:239px; height:70px; z-index:21; clear: both; float: none; } #status { text-align: center; } </style> </head> <body> <div id="apDiv6"> <script type="text/javascript"> <!-- Form Validation --> function validate_form ( ) { valid = true; if ( document.logform.username.value == "" ) { alert ( "Please enter your User Name" ); valid = false; } if ( document.logform.pass.value == "" ) { alert ( "Please enter your password" ); valid = false; } return valid; } <!-- Form Validation --> </script> <div align="center"> <h3><br /> <br /> Log in to your account here<br /> <br /> </h3> </div> <table align="center" cellpadding="5"> <form action="login.php" method="post" enctype="multipart/form-data" name="logform" id="logform" onsubmit="return validate_form ( );"> <tr> <td class="style7"><div align="right">Username:</div></td> <td><input name="username" type="text" id="username" size="30" maxlength="64" /></td> </tr> <tr> <td class="style7"><div align="right">Password:</div></td> <td><input name="password" type="password" id="password" size="30" maxlength="24" /><input type="hidden" name="remember" value="yes" /></td> </tr> <tr> <td> </td> <td><input name="Submit" type="submit" value="Login" /></td> </tr> </form> </table> <br /> </p> </div> <div id="menu"> <ul id="MenuBar1" class="MenuBarHorizontal"> <li><a href="pictures.php">Pictures</a> </li> <li><a href="login.php">Login</a></li> </ul> </div> <script type="text/javascript"> var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"}); </script> </body> </html> Quote Link to comment Share on other sites More sharing options...
Andy-H Posted December 12, 2011 Share Posted December 12, 2011 Sorry mate I gotta go bed my gf is moaning that the keystrokes are keeping her awake. Quote Link to comment Share on other sites More sharing options...
searls03 Posted December 12, 2011 Author Share Posted December 12, 2011 ok, just help me when you can. Quote Link to comment Share on other sites More sharing options...
Andy-H Posted December 13, 2011 Share Posted December 13, 2011 Doesn't work? You getting an error message? What happens? Quote Link to comment Share on other sites More sharing options...
searls03 Posted December 13, 2011 Author Share Posted December 13, 2011 nothing. no error message no nothing. try for yourself. troop78.bammz.net user test pass test Quote Link to comment Share on other sites More sharing options...
Andy-H Posted December 13, 2011 Share Posted December 13, 2011 I get Please log in to access your account. I assume somewhere your script uses session_is_registered to check for logins, wherever this is you need to change it to check if isset($_SESSION['key']) do you have a file called logincheck.php? paste any files (filenames, not code) which are commonly included at the top of pages with include 'file.php'; // or require 'file.php'; // may be include_once or require_once Quote Link to comment Share on other sites More sharing options...
searls03 Posted December 13, 2011 Author Share Posted December 13, 2011 and if it were to be wrong username, it would give a different error. that is the error you get when the sessions isn't set. here is code from the page that it sends you to. <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */include_once "connect_to_mysql.php"; // Here we run a login check if (!isset($_SESSION['id'])) { echo 'Please <a href="/login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include // Place Session variable 'id' into local variable $userid = $_SESSION['id']; // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM members WHERE userid='$userid' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $phone = $row["phone"]; $address = $row["address"]; $city = $row["city"]; $state = $row["state"]; $zip = $row["zip"]; $cell = $row["cell"]; $email = $row["email"]; $accounttype = $row["accounttype"]; $rank = $row["rank"]; $badges = $row["badges"]; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <?php if ($accounttype == "Scout") { ?> <meta HTTP-EQUIV="REFRESH" content="0; url=dashboard.php"> <?php } ?> <?php if ($accounttype == "Scout Master") { ?> <meta HTTP-EQUIV="REFRESH" content="0; url=dashboard.php"> <?php } ?> <style type="text/css"> #apDiv1 { position:absolute; left:226px; top:70px; width:378px; height:293px; z-index:1; } </style> <script type="text/javascript"> function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <?php if ($accounttype == "Admin") { ?> <body onload="MM_preloadImages('button/dash2.png','button/site2.png')"> <div id="apDiv1"><a href="dashboard.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image1','','button/dash2.png',1)"><img src="button/dash1.png" name="Image1" width="420" height="140" border="0" id="Image1" /></a><br /> <br /> <a href="manager.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image2','','button/site2.png',1)"><img src="button/site1.png" name="Image2" width="420" height="140" border="0" id="Image2" /></a></div> <?php } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
Andy-H Posted December 13, 2011 Share Posted December 13, 2011 Thats wierd echo '<pre>'. print_r($_SESSION, 1) .'</pre>'; // Here we run a login check if (!isset($_SESSION['id'])) { echo 'Please <a href="/login.php">log in</a> to access your account'; exit(); } Quote Link to comment Share on other sites More sharing options...
searls03 Posted December 13, 2011 Author Share Posted December 13, 2011 it then gives me this: Array ( ) Please log in to access your account Quote Link to comment Share on other sites More sharing options...
Andy-H Posted December 13, 2011 Share Posted December 13, 2011 <?php // screw that guy, don't know why anyone would put their name to such awful code session_start(); if ( isset($_POST['username']) ) { //Connect to the database include_once "secure/connect_to_mysql_1.php"; $username = mysql_real_escape_string($username); $password = md5($password); // Make query and then register all database data that - // cannot be changed by member into SESSION variables. // Data that you want member to be able to change - // should never be set into a SESSION variable. $query = "SELECT id, username, userlevel FROM sessions WHERE username = '".$username."' AND password = '".$password."' LIMIT 1"; $result = mysql_query($query)or trigger_error('Could not query username/password'); if ( mysql_num_rows($result) ) { $row = mysql_fetch_row($result); // set session variables $_SESSION['id'] = $row[0]; $_SESSION['username'] = $row[1]; $_SESSION['userlevel'] = $row[2]; mysql_query("UPDATE sessions SET lastlogin=now() WHERE id=".$row[0]." LIMIT 1"); // log them in header("location: secure/selector.php"); exit; } else { $error = '<span style="color: #f00;">Sorry, incorrect username or password, please try again!</span><br />'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Login</title> <style type="text/css"> #editregion { position:relative; left:-2px; top:260px; width:1293px; height:51px; z-index:1; text-align: center; clear: none; float: none; } body { background-image: url(button/boyscout1.png); background-repeat: no-repeat; position: relative; } #menu #MenuBar1 li a { color: #000; border-top-style: outset; border-right-style: outset; border-bottom-style: outset; border-left-style: outset; position: relative; cursor: default; filter: Invert; page-break-after: always; width: 100px; } #menu { position:absolute; left:63px; top:177px; width:273px; height:59px; z-index:19; } #status { position:absolute; left:16px; top:180px; width:124px; height:44px; z-index:14; } </style> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}} } </script> <style type="text/css"> #editregion { position:relative; left:-2px; top:260px; width:1293px; height:51px; z-index:1; text-align: center; clear: none; float: none; } body { background-image: url(button/boyscout1.png); background-repeat: no-repeat; position: relative; } #menu #MenuBar1 li a { color: #000; border-top-style: outset; border-right-style: outset; border-bottom-style: outset; border-left-style: outset; position: relative; cursor: default; filter: Invert; page-break-after: always; width: 100px; } #menu { position:absolute; left:63px; top:165px; width:273px; height:59px; z-index:19; } #status { position:absolute; left:16px; top:180px; width:124px; height:44px; z-index:14; } </style> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}} } </script> <style type="text/css"> #apDiv1 { position:absolute; left:33px; top:203px; width:252px; height:48px; z-index:1; } #apDiv2 { position:absolute; left:33px; top:244px; width:254px; height:80px; z-index:2; } #apDiv3 { position:absolute; left:33px; top:367px; width:256px; height:65px; z-index:3; } #apDiv4 { position:absolute; left:33px; top:285px; width:250px; height:61px; z-index:4; } #apDiv5 { position:absolute; left:339px; top:199px; width:263px; height:255px; z-index:5; } #apDiv6 { position:relative; left:-2px; top:260px; width:1293px; height:51px; z-index:1; text-align: center; clear: none; float: none; } #apDiv7 { position:absolute; left:33px; top:326px; width:266px; height:83px; z-index:6; } body { background-image: url(secure/button/boyscout1.png); background-repeat: no-repeat; } </style> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}} } </script> <style type="text/css"> #logout { position:absolute; left:1099px; top:186px; width:134px; height:38px; z-index:20; font-weight: bold; font-size: 24px; } #logout a { color: #000; } #footer { position:absolute; left:98px; top:512px; width:239px; height:70px; z-index:21; clear: both; float: none; } #status { text-align: center; } </style> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <style type="text/css"> #logout { position:absolute; left:1099px; top:186px; width:134px; height:38px; z-index:20; font-weight: bold; font-size: 24px; } #logout a { color: #000; } #footer { position:absolute; left:98px; top:512px; width:239px; height:70px; z-index:21; clear: both; float: none; } #status { text-align: center; } </style> </head> <body> <div id="apDiv6"> <script type="text/javascript"> <!-- Form Validation --> function validate_form ( ) { valid = true; if ( document.logform.username.value == "" ) { alert ( "Please enter your User Name" ); valid = false; } if ( document.logform.pass.value == "" ) { alert ( "Please enter your password" ); valid = false; } return valid; } <!-- Form Validation --> </script> <div align="center"> <?php echo isset($error) ? $error : ''; ?> <h3><br /> <br /> Log in to your account here<br /> <br /> </h3> <> <table align="center" cellpadding="5"> <form action="login.php" method="post" enctype="multipart/form-data" name="logform" id="logform" onsubmit="return validate_form ( );"> <tr> <td class="style7"><div align="right">Username:<></td> <td><input name="username" type="text" id="username" size="30" maxlength="64" /></td> </tr> <tr> <td class="style7"><div align="right">Password:<></td> <td><input name="password" type="password" id="password" size="30" maxlength="24" /></td> </tr> <tr> <td> </td> <td><input name="Submit" type="submit" value="Login" /></td> </tr> </form> </table> <br /> </p> <> <div id="menu"> <ul id="MenuBar1" class="MenuBarHorizontal"> <li><a href="pictures.php">Pictures</a> </li> <li><a href="login.php">Login</a></li> </ul> <> <script type="text/javascript"> var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"}); </script> </body> </html> [/i] That work? Quote Link to comment Share on other sites More sharing options...
searls03 Posted December 13, 2011 Author Share Posted December 13, 2011 it is still doing the same thing Quote Link to comment Share on other sites More sharing options...
Andy-H Posted December 13, 2011 Share Posted December 13, 2011 whats the code in secure/connect_to_mysql_1.php? Quote Link to comment Share on other sites More sharing options...
searls03 Posted December 13, 2011 Author Share Posted December 13, 2011 <?php /* Created By Adam Khoury @ www.developphp.com -----------------------June 19, 2008-----------------------*/ //*** "die()" will exit the script and show an error if something goes wrong with the "connect" or "select" functions. //*** A "mysql_connect()" error usually means your connection specific details are wrong //*** A "mysql_select_db()" error usually means the database does not exist. // Place db host name. Usually is "localhost" but sometimes a more direct string is needed $db_host = "localhost"; // Place the username for the MySQL database here $db_username = ""; // Place the password for the MySQL database here $db_pass = ""; // Place the name for the MySQL database here $db_name = ""; mysql_connect("$db_host","$db_username","$db_pass") or die(mysql_error()); mysql_select_db("$db_name") or die("no database by that name"); ?> with the info filled in Quote Link to comment Share on other sites More sharing options...
Andy-H Posted December 13, 2011 Share Posted December 13, 2011 <?php // screw that guy, don't know why anyone would put their name to such awful code session_start(); if ( isset($_POST['username']) ) { //Connect to the database include_once "secure/connect_to_mysql_1.php"; $username = mysql_real_escape_string($username); $password = md5($password); // Make query and then register all database data that - // cannot be changed by member into SESSION variables. // Data that you want member to be able to change - // should never be set into a SESSION variable. $query = "SELECT id, username, userlevel FROM sessions WHERE username = '".$username."' AND password = '".$password."' LIMIT 1"; $result = mysql_query($query)or trigger_error('Could not query username/password'); if ( mysql_num_rows($result) ) { $row = mysql_fetch_row($result); echo '<pre>' . print_r($row, 1) . '</pre>'; exit; // set session variables $_SESSION['id'] = $row[0]; $_SESSION['username'] = $row[1]; $_SESSION['userlevel'] = $row[2]; mysql_query("UPDATE sessions SET lastlogin=now() WHERE id=".$row[0]." LIMIT 1"); // log them in header("location: secure/selector.php"); exit; } else { $error = '<span style="color: #f00;">Sorry, incorrect username or password, please try again!</span><br />'; } } ?> I honestly don't know then mate, try that^ Quote Link to comment 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.