<?php session_start(); ?>
<?php
if(isset($_POST['txtname']) && isset($_POST['txtname']))
{
$username=$_POST['txtname'];
$password=$_POST['txtpass'];
if(isset($_POST['chlrember']) && $_POST['chlrember'] == 'on')
{
setcookie('txtname',$username, time()+120);
setcookie('txtpass',$password, time()+120);
}
else {
//setcookie("txtname", $username, time()-120);
//setcookie("txtpass", $password, time()-120);
}
}
else {
$username = '';
$password = '';
if(isset($_COOKIE['txtname']))
{ $username=$_COOKIE['txtname']; }
if(isset($_COOKIE['txtpass']))
{ $password=$_COOKIE['txtpass']; }
}
if(isset($_POST['btnlogin']))
{
if( $_POST['txtname']=='admin' && $_POST['txtpass']=='admin')
{
$_SESSION['my']=$_POST['txtname'];
header('location:list.php');
}
else
{
echo "Wrong User name";
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script type="text/javascript">
function chkform(form)
{
if(form.txtname.value=="")
{
form.txtname.focus();
document.getElementById("a1").innerHTML="Enter User Name";
return false;
}
if(form.txtpass.value=="")
{
form.txtpass.focus();
document.getElementById("a2").innerHTML="Enter Your Password";
return false;
}
return true;
}
</script>
</head>
<body bgcolor="#999966">
<form name="lo1" method="post" onSubmit="return chkform(this)">
<table>
<tr>
<tr>
<th>User Name</th>
<td><input type="text" name="txtname" placeholder="Enter User Name" value="<?=$username;?>" ><span id="a1" style="color:red"></span></td>
</tr>
<tr>
<th>Password</th>
<td><input type="password" name="txtpass" placeholder="Enter Pssword" value="<?=$password;?>" ><span id="a2" style="color:red"></span></td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" name="chlrember" > Remember Me</td>
</tr>
<tr>
<td><input type="submit" name="btnlogin" value="Login"></td>
</tr>
</tr>
</table>
</form>
</body>
</html>
<?php
if(isset($_POST['txtname']) && isset($_POST['txtname']))
{
$username=$_POST['txtname'];
$password=$_POST['txtpass'];
if(isset($_POST['chlrember']) && $_POST['chlrember'] == 'on')
{
setcookie('txtname',$username, time()+120);
setcookie('txtpass',$password, time()+120);
}
else {
//setcookie("txtname", $username, time()-120);
//setcookie("txtpass", $password, time()-120);
}
}
else {
$username = '';
$password = '';
if(isset($_COOKIE['txtname']))
{ $username=$_COOKIE['txtname']; }
if(isset($_COOKIE['txtpass']))
{ $password=$_COOKIE['txtpass']; }
}
if(isset($_POST['btnlogin']))
{
if( $_POST['txtname']=='admin' && $_POST['txtpass']=='admin')
{
$_SESSION['my']=$_POST['txtname'];
header('location:list.php');
}
else
{
echo "Wrong User name";
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script type="text/javascript">
function chkform(form)
{
if(form.txtname.value=="")
{
form.txtname.focus();
document.getElementById("a1").innerHTML="Enter User Name";
return false;
}
if(form.txtpass.value=="")
{
form.txtpass.focus();
document.getElementById("a2").innerHTML="Enter Your Password";
return false;
}
return true;
}
</script>
</head>
<body bgcolor="#999966">
<form name="lo1" method="post" onSubmit="return chkform(this)">
<table>
<tr>
<tr>
<th>User Name</th>
<td><input type="text" name="txtname" placeholder="Enter User Name" value="<?=$username;?>" ><span id="a1" style="color:red"></span></td>
</tr>
<tr>
<th>Password</th>
<td><input type="password" name="txtpass" placeholder="Enter Pssword" value="<?=$password;?>" ><span id="a2" style="color:red"></span></td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" name="chlrember" > Remember Me</td>
</tr>
<tr>
<td><input type="submit" name="btnlogin" value="Login"></td>
</tr>
</tr>
</table>
</form>
</body>
</html>
No comments:
Post a Comment