i develop a login form where the user need to fill username & password which i stored in (table1) and also need to enter secret key which i stored in (table2).If username,password & secret key is correct it will display SUCCESSFULLY LOGIN TO USER PROFILE PAGE..." whereas if wrong it will display "SORRY... YOU ENTERED WRONG ID AND PASSWORD... PLEASE RETRY...". Below are my code for login form and connectivity.php.. for now if i enter correct username,password and correct key it will always display wrong message.
<?php
define('DB_HOST', 'localhost');
define('DB_NAME', 'login');
define('DB_USER','root');
define('DB_PASSWORD','');
$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error()); $db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
$Username = $_POST['user']; $Password = $_POST['pass']; $Captcha = $_POST['captcha'];
function SignIn() { session_start();
//starting the session for user profile page
if(!empty($_POST['user']))
//checking the 'user' name which is from Sign-In.html, is it empty or have some text
{
$query = mysql_query("SELECT username.userName, username.pass, ,secret.key where userName = '$_POST[user]' AND pass = '$_POST[pass]' AND key = '$_POST[captcha]'") or die(mysql_error());
$row = mysql_fetch_array($query);
if(!empty($row['userName']) AND !empty($row['pass']) AND !empty($row['captcha']))
{
$_SESSION['userName'] = $row['pass'] = $row['captcha'];
echo "SUCCESSFULLY LOGIN TO USER PROFILE PAGE...";
}
else
{
echo "SORRY... YOU ENTERED WRONG ID AND PASSWORD... PLEASE RETRY...";
}
}
} if(isset($_POST['submit'])) { SignIn();
}
?>
<form method="POST" action="connectivity.php">
User <br><input type="text" name="user" size="40"><br>
Password <br><input type="password" name="pass" size="40"><br>
Captcha <br><input type="password" name="captcha" size="40">
<input id="button" type="submit" name="submit" value="Log-In">
</form>
Aucun commentaire:
Enregistrer un commentaire