Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/73177-unable-to-login-no-error/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.