0

Hi bro,
this is my frame work of the simple login script.

now i want a send the id input to the display.php, without changing this frame work coz i only know this way of making a simple login.

<?php
if (isset($_SESSION['basic_is_logged_in'])) {
   unset($_SESSION['basic_is_logged_in']);
}
session_start();
$errorMessage = '';
if (isset($_POST['name']) && isset($_POST['id'])) {
mysql_connect('localhost', 'root', 'jackson');
mysql_select_db('praveen');
$user = mysql_query("SELECT name FROM `users` WHERE `users`.`id` = '$_POST[id]'");
$row = mysql_fetch_array( $user );
$name = $_POST['name'];
$fetch = $row['name'];
if ( $name == $fetch ) {
$_SESSION['basic_is_logged_in'] = true;
header('Location: display.php');
exit;
} else {
$errorMessage = 'Sorry, wrong user id / password';
}
}
?>
<!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>
</head>

<body>
<?php
if ($errorMessage != '') {
?>
<p align="center"><strong><font color="#990000"><?php echo $errorMessage; ?></font></strong></p>
<?php
}
?>
<form action="" method="POST" name="frmLogin" id="frmLogin">
  <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td>
      <table width="100%" border="0" cellspacing="2" cellpadding="2">
        <tr>
          <td width="40%" align="right"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">User Name:</font></td>
          <td width="60%"><input name="name" type="text" id="name" maxlength="50" /></td>
        </tr>
        <tr>
          <td width="40%" align="right"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">Password:</font></td>
          <td width="60%"><input name="id" type="password" id="id" maxlength="50" /></td>
        </tr>
        <tr>
          <td width="40%">&nbsp;</td>
          <td width="60%"><input name="btnLogin" type="submit" value="Login" id="btnLogin" /></td>
        </tr>
      </table></td>
    </tr>
  </table>
</form>
</body>
</html>
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by lkrvk
0
session_start();
if (isset($_SESSION['basic_is_logged_in'])) {
   unset($_SESSION['basic_is_logged_in']);
}

You also need to clean your variables before putting them into mySQL. Your password is known as id. This is confusing. Which id do you want to pass? The primary key id of the user or the password? I assume the former, but ...?

0

thanks for breaking head on my confusing code
i got it working with the use of

$id = $_SESSION['id'];

in the session start page, then

$_SESSION['id']= $id;

in the session page and got the data to be transferred to next page.
any way thanks for helping me
http://www.lkrvk.com/

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.