<?Php
session_start();
?>
<!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>Demo Login script of plus_signup of plus2net.com</title>
</head>

<body>
<?Php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
include "dbconnect.php"; // database connection details stored here
$userid=$_POST['userid'];
$password=$_POST['password'];
$msg='';
$status='OK';
if(!isset($userid) or strlen($userid) <4){
$msg=$msg."User id should be =4 or more than 4 char length<BR>";
$status= "NOTOK";}	
				
if ( strlen($password) < 6 ){
$msg=$msg."Password must be more than 6 char legth<BR>";
$status= "NOTOK";}					

if($status<>"OK"){ 
echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='history.go(-1)'>";
exit;
}

//////////////////////

$count=mysqli_query($con, "select password,mem_id,userid from plus_signup where userid='$userid' ");
$no=mysqli_num_rows($count);

if($no <> 1 ) 
{
    $msg=" Userid does not exist please try again ... ";
	include "loginall.php"; 
}
else 
{ 
   $row = mysqli_fetch_array($count);
   if($row['password']==md5($password))
       {
        echo " Inside ";
        // Start session n redirect to last page
        $_SESSION['id']=session_id();
         $_SESSION['userid']=$row['userid'];
        $_SESSION['mem_id']=$row['mem_id'];
        //echo " Inside session  ". $_SESSION['userid'];
        $msg=" welcome $_SESSION[userid] loging successfully , please wait ... ";
        echo $msg;
        echo "<script language='JavaScript' type='text/JavaScript'>
        <!--
        window.location='welcome.php';
        //-->
         </script>";
        } 
    else
         {
         $msg = " Login failed, try again ... <br><INPUT TYPE='button' VALUE='Back' onClick='history.go(-1);'>";
		 }// end of if else for matching password
         // end of if else for matching number of records <>1 
}


echo $msg;
}
?>


<br><br>

</body>

</html>
