login

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GaneshPrasad
Forum Newbie
Posts: 5
Joined: Thu Mar 22, 2012 12:50 am

login

Post by GaneshPrasad »

<?php
include("connection.php");
if($_POST['submit'])
{
$myusername = $_POST['username'];
$mypassword = $_POST['password'];
$myadmin = $_POST['admin'];// ok
if($myusername && $mypassword && $myadmin)
{
$sql = mysql_query("select * from login");

while($getrows = mysql_fetch_array($sql))
{
$dbuser = $getrows['Username'];
$dbpass = $getrows['Password'];
$dbrole = $getrows['Role'];
}

if(($myusername == $dbuser) && ($mypassword == $dbpass) && ($dbrole-->"Admin"))
{
header("location:Home.php");
}

else if(($myusername == $dbuser) && ($mypassword == $dbpass) && ($dbrole-->"Member"))

{
header("location:Home.php");
}


//else
//{
//echo "Login Failed......";
//}


}


else
{
echo "username and password failed";
}
}

?>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: login

Post by Celauran »

Is there a question hiding in there somewhere? Also, please use syntax tags to clean up that mess of code.
Post Reply