SOLVED | a simple code problem. please help me out.
Posted: Sun Sep 11, 2005 10:57 am
feyd | Please use
this the php code that will verify the type of user (userVer.php)
i dont know how to go about this. any help or suggestions for me to work this thing out will be very much appreciated. thank you!
feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
hi! ive been reading some of the topics but i can't seem to find the answers i need so here goes:
it's just a simple login page that will direct an admin user to "admin.html" and an ordinary user to "user.html"
this is part of the login interface code (index.html)Code: Select all
<td height="1" width="71%">
<form action="userVer.php" method = POST>
<fieldset style="padding: 2">
<legend><b><font face="Lucida Console" color="#0D4F84">user</font></b><font color="#484848" face="Impact" size="4">Login</font></legend>
<b><font face="Arial" size="2">username :</font></b> <input type="text" name="uName" size="20">
<br>
<b><font face="Arial" size="2">password : </font></b> <input type="password" name="pWord" size="20">
<b><font face="Verdana" size="2" color="#3A4F56">
<input type = "submit" value = "Login">
</fieldset></form>
</td>this the php code that will verify the type of user (userVer.php)
Code: Select all
<?php
$dbCon = mysql_connect ("localhost","root","123456") ;
$dbUse = mysql_select_db("ordersystem", $dbCon) ;
$username = $_POST["uName"] ;
$password = $_POST["pWord"] ;
$userQuery = "select * from uProfile where uName = '$username' and uPass = '$password'" ;
$qResult = mysql_query ($userQuery,$dbCon) ;
$searchRows = mysql_num_rows($qResult) ;
if (!$dbCon)
{
die ("Failed to connect to MySQL!" . mysql_error()) ;
}
else
{
if (!$dbUse)
{
print "Unable to open database!" ;
}
else
{
if (!$searchRows)
{
print "Login Failed : UNAUTHORIZED USER" ;
}
else
{
if ($username == "admin" && $password == "admin")
{
print "Login success : ADMINISTRATOR ACCOUNT" ;
/* insert code here that will redirect user to
admin.html */
}
else if ($username == "user" && $password == "user")
{
print "Login success : USER ACCOUNT" ;
/* insert code here that will redirect user to
user.html */
}
}
}
}
mysql_close();
?>i dont know how to go about this. any help or suggestions for me to work this thing out will be very much appreciated. thank you!
feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]