riya_here Posted October 14, 2007 Share Posted October 14, 2007 Please Help!! I am facing a very strange problem. I used the following script help to create a login script. <? session_start(); // start session. ?> <HTML><HEAD><TITLE>Login</TITLE></HEAD> <BODY> <? if(!isset($username) | !isset($password)) { echo "No Data"; // escape from php mode. ?> <form action="<?=$PHP_SELF?><?if($QUERY_STRING){ echo"?". $QUERY_STRING;}?>" method="POST"> <table align="center" border="0"> <tr> <th> Username: </th> <th> <input type="text" name="username"> </th> </tr> <tr> <th> Password: </th> <th> <input type="password" name="password"> </th> </tr> <tr> <th colspan="2" align="right"> <input type="submit" value="Login"> </form> </th> </tr> </table> </BODY></HTML> <? exit(); } // If all is well so far. session_register("username"); session_register("password"); // register username and password as session variables. echo $username; echo $password; $sql = mysql_query("SELECT * from clnt_auth where user_id = '$username' and pass = '$password'"); $fetch_em = mysql_fetch_array($sql); echo $fetch_em; $numrows = mysql_num_rows($sql); echo $numrows; if($numrows != "0" & $password == $fetch_em["password"]) { $valid_user = 1; } else { $valid_user = 0; } if (!($valid_user)) { session_unset(); // Unset session variables. session_destroy(); // End Session we created earlier. // escape from php mode. ?> <form action="<?=$PHP_SELF?><?if($QUERY_STRING){ echo"?". $QUERY_STRING;}?>" method="POST"> <p align="center">Incorrect login information, please try again. You must login to access this document.</p> <table align="center" border="0"> <tr> <th> Username: </th> <th> <input type="text" name="username"> </th> </tr> <tr> <th> Password: </th> <th> <input type="password" name="password"> </th> </tr> <tr> <th colspan="2" align="right"> <input type="submit" value="Login"> </form> </th> </tr> </table> </BODY></HTML> <? exit(); } ?> There is no additional thing done. The problem is, I am unable to login. There is no error message. I tried debugging the script with echo commands. But none of the echo command is getting displayed except "No Data". I cleared all my cookies also. Please help. Quote Link to comment https://forums.phpfreaks.com/topic/73177-unable-to-login-no-error/ Share on other sites More sharing options...
Aureole Posted October 14, 2007 Share Posted October 14, 2007 Use code tags please... [ code ]Code here.[ / code ] Quote Link to comment https://forums.phpfreaks.com/topic/73177-unable-to-login-no-error/#findComment-369130 Share on other sites More sharing options...
jd2007 Posted October 14, 2007 Share Posted October 14, 2007 try using this : $_SESSION["username"]=$_POST["username"]; $_SESSION["password"]=$_POST["password"]; instead of this: session_register("username"); session_register("password"); don't use session_register anymore.... Quote Link to comment https://forums.phpfreaks.com/topic/73177-unable-to-login-no-error/#findComment-369131 Share on other sites More sharing options...
riya_here Posted October 14, 2007 Author Share Posted October 14, 2007 I tried your suggestion.... but this isnt working either. I am still unable to login. I am also not getting the login fail error message. Quote Link to comment https://forums.phpfreaks.com/topic/73177-unable-to-login-no-error/#findComment-369151 Share on other sites More sharing options...
trq Posted October 14, 2007 Share Posted October 14, 2007 That code is extremely old. $PHP_SELF and $QUERY_STRING no longer exists. Also session_register() has long been depricated. ather than fix the code you have, you might want to find yourself a more current tutorial, or start with the basics. Theres a good free book in my signiture. Quote Link to comment https://forums.phpfreaks.com/topic/73177-unable-to-login-no-error/#findComment-369153 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.