Thursday 8 January 2015

Login form

1.Login.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="login.php" method="post" name="form1">

<div align="center" >
<table width="200" border="1">
  <tr>
    <td>UserId</td>
    <td><input name="t1" type="text" /></td>
  </tr>
  <tr>
    <td>Password</td>
    <td><input name="t2" type="text" /></td>
  </tr>
  <tr>
    <td colspan="2"><input name="s1" type="submit" value="Login" /></td>
   
  </tr>

</table>
</div>
</form>
</body>
</html>

2.Login.php


<?php
include_once("config.php");
session_start();
 if(isset($_POST['s1']))
     {
    $_SESSION['user']=$_POST['t1'];
    $x=$_POST['t1'];
    $y=$_POST['t2'];
 $res=mysql_query("select * from reg where Userid='$x' and Password='$y'");
   
if(isset($_SESSION['user']))
    if(mysql_num_rows($res)>0)
            {
                 echo "Welcome".$_SESSION['user']." user";
                }else
                {
                 echo "Invalid Userid or Password ".$_SESSION['user'];
                 
                }
   
   
         }
?>

No comments:

Post a Comment