New to PHP Here, trying to figure out a couple of things. When users log into the system, I would like for the PHP to look at the Group ID and then run through a system of checks to find a match. Once the Group ID is matched, it will then redirect users to the appropriate webpage. How would I go about doing this with this piece of code?
These are the columns in my table:
Name, Email, Password, Group
Thanks in advance for your help. Looking forward to learning something new!
<?php
$con=mysqli_connect("localhost", "username", "password", "dbName");
//"localhost", "userName" is username; "Password" is password; "dbName" is DB_Name;
if (mysqli_connect_errno($con))
{
echo "MySql Error: " . mysqli_connect_error();
}
$query=mysqli_query($con,"SELECT * FROM user_reg WHERE UserName='$_POST[UserName]' && Password='$_POST[Password]'");
$count=mysqli_num_rows($query);
$row=mysqli_fetch_array($query);
if ($count==1)
{
session_start();
$_SESSION['UserName'] = $_POST['UserName'];
$_SESSION['Password'] = $_POST['Password'];
header("location: redirect.html");
}
else
{
echo "Invalid username or password";
}
mysqli_close($con);
?>