Header Ads

login.php

Thread with Create simple student management system using PHP with MySQL
<?php
$error="";
if(isset($_POST['btnLogin']) and $_POST['btnLogin']="Login")
{


        //Process login
$username=$_POST['username'];
$password=$_POST['password'];
include "db.php";
$sql="select * from user where username='$username'  and password=md5('$password')";
$results=mysql_query($sql) or die("Error on application: ".mysql_error());
$rowcount= mysql_num_rows($results);
if($rowcount>0)
{
//User Available
session_start();
$_SESSION['user']=$user;
header("Location:index.php");

}  
else
{
//Invalied User 
$error="Invalied User name or Password";
}
}
?>
<!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>Untitled Document</title>
<style type="text/css">
<!--
.style2 {
color: #000000;
font-weight: bold;
font-size: 16px;
}
.style3 {color: #FF0000}
-->
</style>
</head>


<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <table width="400" border="0"  align="center">
    <tr bgcolor="#6666FF">
      <td colspan="2"><span class="style2">Login</span></td>
    </tr>
    <tr>
      <td width="115" bordercolor="#CCCCCC" bgcolor="#CCCCCC">&nbsp;</td>
      <td width="275" bordercolor="#CCCCCC" bgcolor="#CCCCCC">&nbsp;</td>
    </tr>
    <tr>
      <td bordercolor="#CCCCCC" bgcolor="#CCCCCC"><strong>User Name</strong></td>
      <td bordercolor="#CCCCCC" bgcolor="#CCCCCC"><input name="username" type="text" id="uname" size="30" maxlength="20" /></td>
    </tr>
    <tr>
      <td bordercolor="#CCCCCC" bgcolor="#CCCCCC"><strong>Password</strong></td>
      <td bordercolor="#CCCCCC" bgcolor="#CCCCCC"><input name="password" type="password" id="pass" size="30" maxlength="20" /></td>
    </tr>
    <tr>
      <td bordercolor="#CCCCCC" bgcolor="#CCCCCC">&nbsp;</td>
      <td bordercolor="#CCCCCC" bgcolor="#CCCCCC"><input type="submit" name="btnLogin" id="btnLogin" value="Login" />
      <input type="reset" name="button2" id="button2" value="Reset" /></td>
    </tr>
    <tr>
      <td colspan="2" bordercolor="#CCCCCC" bgcolor="#CCCCCC"><span class="style3"><?php echo $error; ?> </span></td>
    </tr>
  </table>
</form>
</body>
</html>

No comments

Thank you very much for your ideas!