need help on multi user login page

General discussions related to php

Moderators: macek, egami, gesf

Leisure
New php-forum User
New php-forum User
Posts: 3
Joined: Wed Jan 23, 2013 12:24 am

need help on multi user login page

Postby Leisure » Wed Jan 23, 2013 12:30 am

<?php
if( !isset($_SESSION) ) { session_start(); }
$database_db="child";
$user_db="root";
$password_db="admin";
$host_db="localhost";

$link=mysql_connect($host_db,$user_db,$password_db) or die ("couldnot connect: ".mysql_error());
mysql_select_db($database_db, $link) or exit('Error Selecting database: '.mysql_error()); ;

$userid=$_POST["userid"];
$password=$_POST["password"];
$type=$_POST["type"];
$errormessage = "";

$sql="SELECT * FROM login where username='$userid' and password='$password' and type='$type'";
$result = mysql_query($sql, $link) or exit('$sql failed: '.mysql_error());
$num_rows = mysql_num_rows($result);
if($num_rows==0){
header("Location: error.php");
} elseif ($num_rows==1) {
if ($type == 1){
header("Location: testadmin.php");
} elseif($type == 2){
header("Location: testuser.php");
}
else
exit;
}
?>


in my phpmyadmin database named "child"

i've placed a table named "login" with three fields namely usename password and type

i need to do a log-in page wherein it can redirect the user depending on his type...

type 1 is an admin and type 2 is a user...

i've been trying to work around it for days..

please help guys this is my first time posting.. thanks to those who will reply

satalways
New php-forum User
New php-forum User
Posts: 5
Joined: Thu Jan 24, 2013 6:39 am
Location: Lahore, Pakistan
Contact:

Re: need help on multi user login page

Postby satalways » Thu Jan 24, 2013 7:00 am

I think everything is fine in your codes. What problem you are facing?

Leisure
New php-forum User
New php-forum User
Posts: 3
Joined: Wed Jan 23, 2013 12:24 am

Re: need help on multi user login page

Postby Leisure » Thu Jan 24, 2013 7:13 pm

it does not redirect to the page that i want it to go :(

Leisure
New php-forum User
New php-forum User
Posts: 3
Joined: Wed Jan 23, 2013 12:24 am

Re: need help on multi user login page

Postby Leisure » Fri Jan 25, 2013 3:33 pm

i found another way around using switch and case :D :D


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron