am doing a classroom project but am stuck with the registering users script it does send the data to the mysql database ppliz help me out thanks
here are both the html and php codes .
<!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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body><form action="reg1.php" method="POST">
<table width="380" height="126" border="1" align="center">
<tr>
<td colspan="3"><div align="center">Register to login in the database </div></td>
</tr>
<tr>
<td width="153">Enter user Name </td>
<td width="181"><input type="text" name="username"> </td>
<td width="24"> </td>
</tr>
<tr>
<td>Enter Password </td>
<td><input type="password" name="pass" /></td>
<td> </td>
</tr>
<tr>
<td>Renter password </td>
<td><input type="password" name="pass2" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Submit" /> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<?php
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("kawempe_hc") or die(mysql_error());
//This code runs if the form has been submitted
if (isset($_POST['submit'])) {
//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
die('You did not complete all of the required fields');
}
// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($check2 != 0) {
die('Sorry, the username '.$_POST['username'].' is already in use.');
}
// this makes sure both passwords entered match
if ($_POST['pass'] != $_POST['pass2']) {
die('Your passwords did not match. ');
}
// here we encrypt the password and add slashes if needed
$_POST['pass'] = md5($_POST['pass']);
if (!get_magic_quotes_gpc()) {
$_POST['pass'] = addslashes($_POST['pass']);
$_POST['username'] = addslashes($_POST['username']);
}
// now we insert it into the database
$insert = "insert into users(username, password)
VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
$add_member = mysql_query($insert);}
?>