Jump to content

admin/user loggin help please!


burge124

Recommended Posts

hi,

 

ive got this login system, i want users to go off to their userhome page, however i have one admin (UserName remains "admin" throughout) where when they loggin they are moved to modhomepage.

 

Does anyone have a suggestion to my problem? im thinking if else statement, but it might get confusing as their is already an if else statement present!

 

ian

 

<?php

ob_start();

$host="localhost"; // Host name

$username="root"; // Mysql username

$password=""; // Mysql password

$db_name="questiondb"; // Database name

$tbl_name="user"; // Table name

 

// Connect to server and select databse.

mysql_connect("$host", "$username", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

 

$UserName=$_POST['UserName'];

$Password=$_POST['Password'];

 

 

$sql="SELECT * FROM $tbl_name WHERE username='$UserName' and password='$Password'";

$result=mysql_query($sql);

if($result){

}

 

//mysql_num_row is counting table row

$count=mysql_num_rows($result);

//if result match  $UserName  and Password  table row must be 1 row

 

if($count==1){

session_register("UserName");

session_register("Password");

header("location:user_homepage.php");

}

else {

echo "Wrong Username or Password";

}

ob_end_flush();

?>

Link to comment
https://forums.phpfreaks.com/topic/93106-adminuser-loggin-help-please/
Share on other sites

<?php
if($count==1){
session_register("UserName");
session_register("Password");
if ($username == "admin") {
    header("location: modhomepage.php");
    }
header("location:user_homepage.php");
}
else {
echo "Wrong Username or Password";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.