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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.