Professional Documents
Culture Documents
<head>
<style type="text/css">
input{
border:1px solid olive;
border-radius:5px;
}
h1{
color:darkgreen;
font-size:22px;
text-align:center;
}
</style>
</head>
<body>
<h1>Login for student<h1>
<form action='#' method='post'>
<table cellspacing='5' align='center'>
<tr><td>User name:</td><td><input type='text' name='name'/></td></tr>
<tr><td>Password:</td><td><input type='password' name='pwd'/></td></tr>
<tr><td><img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchai
mg' ><br></td></tr>
<tr><td><label for='message'>Enter the code above here :</label><br></td></tr>
<tr><td><input id="6_letters_code" name="6_letters_code" type="text"><br></td></
tr>
<tr><td><small>Can't read the image? click <a href='javascript: refreshCaptcha()
;'>here</a> to refresh</small></td></tr>
<tr><td><input type='submit' name='submit' value='Submit'/></td></tr>
</table>
</form>
<script language='JavaScript' type='text/javascript'>
function refreshCaptcha()
{
var img = document.images['captchaimg'];
img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.ra
ndom()*1000;
}
</script>
<?php
if (!isset($_COOKIE['visits']))
{
$_COOKIE['visits'] = 0;
}
$visits = $_COOKIE['visits'] + 1;
setcookie('visits',$visits,time()+3600*24*365);
session_start();
if(isset($_POST['submit']))
{
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('abc') or die(mysql_error());
$name=$_POST['name'];
$pwd=$_POST['pwd'];
if($name!=''&&$pwd!='')
{