This is my Table structure
CREATE TABLE `user_table` (
`id` int(11) NOT NULL,
`username` varchar(50) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`password` varchar(50) DEFAULT NULL,
`type` varchar(50) DEFAULT NULL,
`status` varchar(50) DEFAULT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `user_table`
--
INSERT INTO `user_table` (`id`, `username`, `email`, `password`, `type`, `status`, `date`) VALUES
(11, 'krishan', '
[email protected]', '1234', '1', '0', '2017-05-30 10:36:07'),
(14, 'krishan sahani', '
[email protected]', '12345', '2', '0', '2017-05-31 07:16:08');
and this is my login code....thanks in advance..
session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require('dtb.php');
if(isset($_POST['submit'] )) {
$username = $_POST['username'];
$password =$_POST['password'];
$result = mysqli_query($con,"SELECT username FROM user_table WHERE username = '$username' AND password = '$password' AND type='1'");
if(mysqli_num_rows($result) ==1) {
header("Location: dash.php");
exit;
}
$result = mysqli_query($con,"SELECT username FROM user_table WHERE username = '$username' AND password = '$password'");
if(mysqli_num_rows($result)==1) {
$_SESSION['username'] = $username;
header("Location: profile.php");
exit;
}
else {
?>
<h1 style="color:darkred;margin-left:30px;">Wrong Username and Password </h1>
<?php
}
}
?>
<html>
<h1>Log In</h1>
<head>
<link rel="stylesheet" type="text/css" href="style1.css">
</head>
<form action="" method="post">
<input type="text" name="username" placeholder="Username" required />
<input type="password" name="password" placeholder="Password" required />
<input name="submit" type="submit" value="Login" />
</form>
<p>Not registered yet? <a href='register1.php'>Register Here</a></p>
</html>