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 {
?>
}
}
?>
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 {
?>
Wrong Username and Password
}
}
?>
Log In
Not registered yet? Register Here

Kesavan KrishnanPosted Jun 6, 2017, 9:02 AM
Karthi KeyanPosted Jun 1, 2017, 11:52 PM
if(mysqli_num_rows($result) ==1)