Jump to content

Recommended Posts

this code is to match the username and the password in the database and if correct it will redirect... can some1 tell me which part in this code is masked the password ?? i cant figure it out... and i need the masking to mask the password when the user register themself ...(this code will masked the password when the user type)

 

 

<?php
// we must never forget to start the session
session_start();

$errorMessage = '';
if (isset($_POST['username']) && isset($_POST['password'])) {
include 'library/config.php';
include 'library/opendb.php';

$userId   = $_POST['username'];
$password = $_POST['password'];

// check if the user id and password combination exist in database
$sql = "SELECT username 
        FROM register
		WHERE username = '$userId' AND password = '$password'";

$result = mysql_query($sql) or die('Query failed. ' . mysql_error()); 

if (mysql_num_rows($result) == 1) {
	// the user id and password match, 
	// set the session
	$_SESSION['db_is_logged_in'] = true;

	// after login we move to the main page
	header('Location: main.php');
	exit;
} else {
	$errorMessage = 'Sorry, wrong user id / password';
}

include 'library/closedb.php';
}
?>
<html>
<head>
<title>Basic Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</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="400" border="1" align="center" cellpadding="2" cellspacing="2">
  <tr>
   <td width="150">Username</td>
   <td><input name="username" type="text" id="username"></td>
  </tr>
  <tr>
   <td width="150">Password</td>
   <td><input name="password" type="password" id="password"></td>
  </tr>
  <tr>
   <td width="150"> </td>
   <td><input name="btnLogin" type="submit" id="btnLogin" value="Login"></td>
  </tr>
</table>
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/51220-solved-where-is-the-masked-password/
Share on other sites

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.