Login Form Code As Category System:
Sometime you have to redirect user according to his category / position to specific page. So, here this login form code can help you. It is simple code and localhost tested.
<?php
//header('location: index.php');
//session_start();
function confirm_query($data)
{
if(!$data)
die("Query Failed: " . mysqli_connect_error());
}
$username = $_POST['username'];
$password = $_POST['password'];
$host = "localhost";
$dbuser = "root";
$dbpass = "";
$db = "estate";
$con = mysqli_connect($host, $dbuser); //Connection with server
confirm_query($con);
$connection = mysqli_select_db($con, $db); //Database is connected here
confirm_query($connection);
if(isset($_POST['submit']))
{
$query = "SELECT * FROM users where username = '{$username}' and password = '{$password}';";
$all_users = mysqli_query($con, $query);
if(!$all_users)
echo 'user pass query not working;' . mysqli_connect_error();
$user = mysqli_fetch_array($all_users);
if(mysqli_num_rows($all_users) != 0)
{
if($username == $user[username] AND $password == $user[password])
{
if($user[Category] == "Receptionist")
{
$_SESSION['username'] = $username;
header("location: receptionist.html");
exit;
}
//Example Like uncomment and change.
//make sessions and add code start_session(); in all pages start.
/*elseif($user[Category] == "Receptionist")
{
$_SESSION['username'] = $username;
header("location: receptionist.html");
exit;
}*/
}
}
}
else
{
header("location: login.html");
exit;
}
?>
+ comments + 2 comments
Thanks for giving important information to training seekers,Keep posting useful information..
PHP Training Institutes in Chennai
Its best example for creating signup form using php
by
Sri Priya( Web Designing Training in Chennai )
Post a Comment
Give your reviews about this blog. Leave your comments. What do you think about this post?
Comments Guidelines:
1) I love to read comments, but please avoid spam.
2) Like this blog, share your insights, and spread the word.
3) You can use basic HTML/xHTML tags.
4) All comments are DoFollow—please use the section professionally.
5) Kindly mention your name or brand below your comment.
6) Constructive suggestions for improvement are always welcome.
7) Do not forget to explore our main agency platform at pingbooster.site.
Thanks for visiting Samee Articles.
========================================
Explore custom digital solutions and WordPress plugins at PingBooster Plugins.
Best Regards,
Samee U. Feroz