I have created a login form, when the user enters their user and pass it checks the table in the database I have created. If the user and pass is there they should get a welcome screen or admin screen depending on their 'auth' number in the database (1- admin 2- welcome). so far it just displays the welcome screen. How can I incorporate 'auth' from the table in the code so it will display the proper screen? Is it possible to do something like if ($send != "no" && $row['auth']== 2) { ?
this is what I have so far:
if ($_POST['username']=="" || strlen($_POST['username'])>6 && 8 &&(!preg_match("/^[a-zA-Z0-9]+$/", ($_POST['user']) != True))){
$username_err = "<font color=red>Username must have 6 to 8 characters.</font><br>";
$send ="no";
}
if ($_POST['password']=="" || (!preg_match("/^.*(?=.{8,})(?=.*[0-9])(?=.*[A-Za-z]).*$/", ($_POST['password'])))){
$password_err = "<font color=red>Password must contain both alpha and numeric characters.</font><br>";
$send= "no";
}
if ($send != "no"){
$con = mysql_connect("localhost", "root", "password");
echo mysql_select_db("test", $con);
$sql = "SELECT * FROM login WHERE username = '".$_POST['username']."' OR password = '".$_POST['password']."'";
$result = mysql_query($sql) or die("Query error: ".mysql_error());
if ($row = mysql_fetch_array($result))
{
$query = "SELECT * FROM login WHERE username= '".$_POST['username']."'";
echo "<h3>Welcome {$row['fname']} " . "{$row['lname']}</h3>";
}
}
else {
$con = mysql_connect("localhost", "root", "password");
echo mysql_select_db("test", $con);
$sql = "SELECT * FROM login WHERE username = '".$_POST['username']."' OR password = '".$_POST['password']."'";
$result = mysql_query($sql) or die("Query error: ".mysql_error());
if ($row = mysql_fetch_array($result))
{
header("Location: main.php");
exit;
} }
login form help
Moderator: General Moderators
Re: login form help
Hi
Is there a value for each user for auth.
If yes then we can get the values from the database depending upon the username and password,We can set the page.
Ie If auth==1 ,Then admin page .
If auth=2 then welcome page.
Thanks
Is there a value for each user for auth.
If yes then we can get the values from the database depending upon the username and password,We can set the page.
Ie If auth==1 ,Then admin page .
If auth=2 then welcome page.
Thanks