PSP Hacks - Forums

Go Back   PSP Hacks - Forums > Tech Talk > PC Programming

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-29-2009, 06:30 AM
Adi5 Adi5 is offline
PSP Newbie
 

Join Date: May 2005
Posts: 41
Adi5 Has a Beginner Reputation
Default Login page with different levels

Hello Gods
It is I your mortal servant hoping you might impart some of your wisdom on my puny brain.

I want to create a login page that sends people to different pages depending on their level. I have a database with username, password and level in it. In level i have level 1, level 2 and level 3. Now if a username that is in the database is level 1 i want it to send me to page 1 if it is level 2 i want it to send me to page 2.
I have no idea how to accomplish this since i don't want to force people to type in their level with the username and password. I want the code to basically see what the username is and if it does exist in the database it should check on what level the username is. I tried doing this with cases but couldn't get it to work
Here is my code related to the whole thing.

These are just the forms from where it takes the username and password


<td width="100" class="left"><form id="form2" name="form2" method="post" action="login.php">&nbsp;&nbsp;&nbsp;Username</td>
<td><input name="username" type="text" id="username" size="15" /></td>
</tr>
<tr>
<td width="100" class="left">&nbsp;&nbsp;&nbsp;Password</td>
<td><input name="password" type="password" id="password" size="15" /></td>
</tr>
<tr>
<td width="100">&nbsp;</td>
<td><input type="submit" name="Submit" value="Login" /></td>
</tr></table></td>


And this is my php code for connecting to the database and checking if the username and password typed in the page above exists in the database and here i attempt to use cases but i fail.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title></head>
<body>
<?php
extract( $_POST );
$conn = mysql_connect("localhost", "root", "pokemon");

mysql_select_db("dino", $conn);

if(!$conn)
{
echo "Can not connect to the database";
}

$result = mysql_query("select * from login where username ='".$_POST['username']."' and password ='".$_POST['password']."' and Nivo='".$_POST['Nivo']."'");

$c=0;
while ($row = mysql_fetch_array($result)){
$c++;
}


if($c>0)
{
switch($result){
case "1":
header("Location: home.html");
break;
case "2":
header("Location: tenderi.php");
break;
case "3":
header("Location: komitenti.php");
break;
}

}


if($c==0){
header("Location: restricted.php");
}

mysql_close($conn);

?>
</body>
</html>




Thanks in advace from a mere mortal
__________________
Life\'s a bitch....
...and i\'m its Pimp
Reply With Quote
 

 



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:03 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©