m4tt1986 Posted May 31, 2008 Share Posted May 31, 2008 Hi guys, I am fairly new to PHP and am trying to learn it by looking at the code and playin with things. I have a script to which I have insatlled but when you try to log in to the admin backend you type in your user name and password and it resets the page and displays the following at the end of the URL "index.php?error=wu" I have been looking at the code and I THINK the log in page doesn't know what to do with the information. The index.php code (The page you type in the user name and password) looks like this: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta http-equiv="Content-Language" content="en-us"> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <link rel="stylesheet" href="stylesheet.css" type="text/css"> <title>Control Panel</title> <script language="JavaScript"> <!-- function checkifvalid(){ if (window.document.myform.username.value=="") { alert("please enter your user name!"); window.document.myform.username.focus(); return false; } if (window.document.myform.lpassword.value=="") { alert("please enter your password!"); window.document.myform.lpassword.focus(); return false; } return true; } </script> </head> <script language="JavaScript"> </script> </head> <body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FCFAF7" text="#000000" > <div align="left"> <table border="0" cellpadding="0" cellspacing="0" width="100%" height="41"> <tr> <td width="150%" bgcolor="#000000" height="1"></td> </tr> <tr > <td width="100%" align="left" valign="bottom" bgcolor="#FFFFFF" class="topheader" > Control Panel </td> </tr> </table> </div> <div align="left"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="1"> <img border="0" src="transparent.gif" width="1" height="200"></td> <td width="100%" valign="top" align="center"><br> <br> <br> <br> <table width="33%" height="45%" cellpadding="0" cellspacing="0" class="mytable"> <tr> <td><div align="center"> <table border="0" width="100%" height="100%"> <form method="post" name="myform" action="adminhome.php" onsubmit="javascript: return checkifvalid();"> <tr > <td class="header" width="100%" height="19" colspan="2">Login</td> </tr> <tr> <td width="50%" height="19"><font face="Verdana" size="2">User Name</font></td> <td width="50%" height="19"><input type="text" name="username" size="20"></td> </tr> <tr> <td width="50%" height="19"><font face="Verdana" size="2">Password</font></td> <td width="50%" height="19"><input name="lpassword" type="password" id="lpassword" size="20"></td> </tr> <tr> <td width="100%" colspan="2" height="17"> <p align="center"> <input type="submit" value="Submit" name="B1"> </td> </tr> </form> </table> </div></td> </tr> </table></td> </tr> </table> </div> </body> </html> and the login.php (I assume the page that tell the index.php page what to do with the information looks like this: <? include("../config.php"); $username=trim($username); $password=trim($lpassword); if($username=="" || $password =="") { header("Location: index.php?error=wu"); exit; } $sql="select password from admin where username='$username'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $dbpass=$row[0]; } if($dbpass==$password) { session_start(); $admin_username=$username; session_register("admin_username"); } else { header("Location: index.php?error=wu"); exit; } ?> Any ideas what is wrong and how to correct this. Thanks in advance for any help M4TT Quote Link to comment Share on other sites More sharing options...
ILYAS415 Posted May 31, 2008 Share Posted May 31, 2008 change... $username=trim($username); $password=trim($lpassword); to... $username=trim($_POST['username']); $password=trim($_POST['lpassword']); Then it should work. If it doesnt try changing the form action (on index page) to login.php instead of adminhome.php Quote Link to comment Share on other sites More sharing options...
m4tt1986 Posted May 31, 2008 Author Share Posted May 31, 2008 first suggestion worked a treat thanks 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.