Here is what I have tried so far. I left the errors for testing purposes. I also changed the id to the primary key. I still can create more than one account with the same user name.
I would think that I need to check this before writing it to the table.
Thanks for the help so far. Any other suggestions?
$dbNewUser = $_REQUEST['newuser']; // this gets the user name from the register.html form
$dbNewPassword = $_REQUEST['newpassword']; // this gets the password from the register.html form
$dbh=mysql_connect ("localhost", "hrpjeff_root", "password") or die ('I cannot connect to the database because: ' . mysql_error()); // this connects to the database of dies
$query = "INSERT INTO users (id, name, password) VALUES ( 0, '$dbNewUser', MD5( '$dbNewPassword' ) )"; // this inserts the new user name and password into the table
//$result = mysql_query($query) or die("Query failed: " . mysql_error()); // if it is not saved then a error is thrown
//header( "Location: index.php" ); // redirect to the login if registration is successful.
$result = mysql_query($query);
if(mysql_errno() == 1062) // duplicate entry error
echo " // output error message telling user to try another login ID";
echo "// some other error, so log it and display general error message to users";
echo "// new user account successfully created";