burge124 Posted February 26, 2008 Share Posted February 26, 2008 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 More sharing options...
timmy0320 Posted February 26, 2008 Share Posted February 26, 2008 <?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"; } ?> Link to comment https://forums.phpfreaks.com/topic/93106-adminuser-loggin-help-please/#findComment-476998 Share on other sites More sharing options...
burge124 Posted February 26, 2008 Author Share Posted February 26, 2008 yeah that works a treat! Link to comment https://forums.phpfreaks.com/topic/93106-adminuser-loggin-help-please/#findComment-477010 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.