Friday, 17 April 2015

loginform.php

<?phpsession_start();?>
<html>
    <head>
    <script type="text/javascript">
function chk()
{

if(chk1() && chk2())
{
 if(chk3())
 {
return true;
}
}
return false;
 }
function chk1()
{
var elem=document.getElementById("txt1");
  if(elem.value=="")
  {
  document.getElementById("a").innerHTML="please enter email!";
   return false;
  }
  else
 {
document.getElementById("a").innerHTML="";
return true;
 }
 }
function chk2()
{
var elem=document.getElementById("txt2");
var alphaExp = /^([A-Za-z0-9\-\.\_])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(elem.value.match(alphaExp))
{
 document.getElementById("a").innerHTML="";
return true;
  }
else
  {
document.getElementById("a").innerHTML="please enter valid email!";
elem.focus();
 return false;
 }
 }
 function chk3()
{
var elem=document.getElementById("txt1");
  if(elem.value=="")
  {
  document.getElementById("b").innerHTML="please enter password!";
   return false;
  }
  else
 {
document.getElementById("b").innerHTML="";
return true;
 }
 }
</script>

    </head>
    <body>
<div  align="center" style="background-color:#87CEFA;width:400px;height:250px;margin-left:33.3%" >
<h1>LOGIN HERE</h1>

<form method="post" onsubmit="return chk();">
        <table border="0" style="font-size:20px">
           
            <tbody>

                <tr>
                    <td><i>USER-NAME:</i></td>
                    <td><input type="text" name="username" value="" /><span id="a"></span></td>
                </tr>

                <tr>
                    <td><i>PASSWORD:</i></td>
                    <td><input type="password" name="password" value="" /><span id="b"></span></td>
                </tr>

                <tr>
                    <td><i>USER-TYPE:</i></td>
                    <td><select name="usertype">
                            <option>--SELECT--</option>
                            <option value="powner">PROPERTY OWNER</option>
                            <option value="pseekar">PROPERTY SEEKER</option>
                        </select></td>
                </tr>
            </tbody>
        </table><br/>

<input type="submit" value="LOGIN" name="btn"/>
<br/>
</form>
       <a href=""><i>FORGOT Password???</i></a>


    </body>
</div>
</html>
<?php
if(isset($_POST['btn']))
{
mysql_connect('localhost','root');
mysql_select_db('ibuyhome');
$data=$_POST['usertype'];
if($data=='powner')
{
$query="select * from property_owner where email='".$_POST ['username']."'  and password='".$_POST ['password']."'";
$d=mysql_query($query);
$row=mysql_fetch_array($d);
if(mysql_num_rows($d)==1)
{
$_SESSION ['id']=$row ['owner_id'];
header ('location:dashowner1.php');
}
else
{
echo "Wrong email-id or password";
}}
else if($data=='pseeker')
{
$query="select * from propertyseeker where Emailid='".$_POST ['username']."'  and Password='".$_POST ['password']."'";
$d=mysql_query($query);
$row=mysql_fetch_array($d);
if(mysql_num_rows($d)==1)
{
$_SESSION ['id']=$row ['Id'];
header ('location:dashseeker.php');
}
else
{
echo "Wrong email-id or password";
}}

}
else {
echo"PLEASE MAKE A SELECTION AS SEEKER OR OWNER";
}

?>

0 comments:

Post a Comment