I need help with this php script, it is for my science fair progect which is due on monday.
When i enter the [access] code, no matter what, it just gives a blank page.
code:
<?php
if(isset($_POST['code']))
{
$dbh = mysql_connect ("localhost", "user", "passwurd") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("science");
mysql_real_escape_string($code);
$query = mysql_query("SELECT * FROM codes WHERE code='$code'");
if(mysql_num_rows($query) != 0)
{
mysql_query("DELETE FROM codes WHERE code='$code'");
session_start();
header("Location: http://foo.com/1.php");
}
}
else
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title></title>
</head>
<body>
Welcome,<br>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="validate">Enter
your access code: <input maxlength="6" name="code"><br>
<br>
<input type="submit"><br>
</form>
</body>
</html>
<?php
}
?>
Please and thankyou this is really important