<form name="form" method="post" action="" >
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" name="Submit" value="LOGIN" />
<?php
if($message !="")
{
echo $message;
}
?>
</form>
<?php
include("config.php");
session_start();
// if(isset($_POST["username"])){
// $username1 = $_POST["username"];
// $_SESSION["username"] = $username1;
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$username = $_POST["username"];
$password = $_POST["password"];
$querySelect = "select * from login where name = '$username' and password = '$password' and status ='1'";
$resultSelect = mysql_query($querySelect);
//echo $querySelect;
$count = mysql_num_rows($resultSelect);
//echo $count;
//IF COUNT >0 RETRIEVE DATA FROM QUERY .ELSE GO BACK TO LOGIN
if($count>0){
$row=mysql_fetch_row($resultSelect);
$loginid = $row[0];
$role = $row[3];
$username = $row[1];
$_SESSION['id'] = $loginid;
$_SESSION['user'] = $username;
header("Location:home.php");
}
else
//echo("Please Enter Correct Username and Password ...");
header("Location:index.php?flagReg=1");
}
$message = "";
if(isset($_GET["flagReg"])){
$flagReg = $_GET["flagReg"];
if($flagReg == '1'){
$message = "Please Enter Correct Username and Password";
}
}
?>
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" name="Submit" value="LOGIN" />
<?php
if($message !="")
{
echo $message;
}
?>
</form>
<?php
include("config.php");
session_start();
// if(isset($_POST["username"])){
// $username1 = $_POST["username"];
// $_SESSION["username"] = $username1;
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$username = $_POST["username"];
$password = $_POST["password"];
$querySelect = "select * from login where name = '$username' and password = '$password' and status ='1'";
$resultSelect = mysql_query($querySelect);
//echo $querySelect;
$count = mysql_num_rows($resultSelect);
//echo $count;
//IF COUNT >0 RETRIEVE DATA FROM QUERY .ELSE GO BACK TO LOGIN
if($count>0){
$row=mysql_fetch_row($resultSelect);
$loginid = $row[0];
$role = $row[3];
$username = $row[1];
$_SESSION['id'] = $loginid;
$_SESSION['user'] = $username;
header("Location:home.php");
}
else
//echo("Please Enter Correct Username and Password ...");
header("Location:index.php?flagReg=1");
}
$message = "";
if(isset($_GET["flagReg"])){
$flagReg = $_GET["flagReg"];
if($flagReg == '1'){
$message = "Please Enter Correct Username and Password";
}
}
?>
No comments:
Post a Comment