Wednesday, June 6, 2012

PHP(Simple Login)

<!--php-->
<?php
$host="localhost";
$user="password";
$pass="";
$db="test";
mysql_connect($host,$user,$pass);
mysql_select_db($db);

//if username is not be empty
if(isset($_POST['username'])){
    $username= $_POST['username'];
    $password = $_POST['password'];

    $sql ="SELECT * FROM Login WHERE Username='".$username."' AND Password='".$password."' AND STATUS = 'A' LIMIT 1";
    $res = mysql_query($sql);
    if(mysql_num_rows($res) == 1)
    {
        header('Location: FirstPrj.php');
        exit(); 
    }else    {
        echo "Invalid login information please provide authentic information";
        exit();     
    }
}
?>
<!--end php-->

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
</head>
<body>
    <form method="post" action="login.php">
        Username:<input type="text" name="username" /><br/> <br/>
        Password:<input type="password" name="password"/><br/><br/>
        <input type="submit" name="submit" value ="Login"/>
    </form>
</body>
</html>

No comments:

Post a Comment