Tuesday, 28 August 2018
Subscribe to:
Post Comments (Atom)
<?php
session_start();
mysql_connect ('localhost', 'root', 'root') or die('NO MYSQL CONNECTION!');
mysql_select_db('login');
if ($_GET['login']) {
$username = ($_POST['username']);
$password = ($_POST['password']);
$tmp = mysql_query("SELECT * FROM `user`");
$data = mysql_fetch_array($tmp);
if($tmp) {
echo 'FULL<br />';
} else {
echo 'EMPTY<br />';
}
$_SESSION['username'] = $data['username'];
$_SESSION['password'] = $data['password'];
if ($username == $_SESSION['username'] && $password == $_SESSION['password']) {
$_SESSION['loggedin'] = true;
header("Location: protected.php");
exit;
} else echo "Wrong details!<br />";
}
if ($_SESSION['loggedin'] == true) {
header("Location: protected.php");
}
?>
userTBL
WHERE username = {$username} AND password = {$password}"); The 'WHERE' clause will ensure that the query only returns data matching the username and password that was typed into the form.Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment