Her er hele min kode, hvis det er til hjælp:
<?php include ('db_connect.php');?>
<!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>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function validation() {
var invalid = " "; // Invalid character is a space
var minLength = 6; // Minimum length password
var minLength2 = 4; //minimum length username
var pw1 = document.create.password.value;
var pw2 = document.create.password2.value;
var name = document.create.name.value;
// check for a value in both fields.
if (pw1 == '' || pw2 == '') {
alert('Please enter your password twice.');
return false;
}
//check for value in name
if (document.create.name.value == "") {
alert ("Username required");
return false;
}
// check for minimum length password
if (document.create.password.value.length < minLength) {
alert('Your password must be at least ' + minLength + ' characters long. Try again.');
return false;
}
// check for minimum length Username
if (document.create.name.value.length < 4) {
alert('Your username must be at least 4 characters long. Try again.');
return false;
}
// check for spaces password
if (document.create.password.value.indexOf(invalid) > -1) {
alert("Your password may not contain any spaces.");
return false;
}
// check for spaces username
if (document.create.name.value.indexOf(invalid) > -1) {
alert("Your username may not contain any spaces.");
return false;
}
else {
if (pw1 != pw2) {
alert ("You did not enter the same password twice. Please re-enter your password.");
return false;
}
else {
return true;
}
}
}
// End -->
</script>
</HEAD>
</head>
<body>
<p>
<?php
if (isset ($_POST['Submit' ]))
{
$name = $_POST['name' ];
$password = $_POST['password' ];
$query = "INSERT INTO accounts (name, password) VALUES('$name', '$password')" ;
mysql_query ($query );//kører forespørgsel
mysql_close ();
header ("location:confirm.php" );
}
?>
<!-- comment
?php
$query = mysql_query("SELECT name FROM accounts WHERE name = '$name' LIMIT 1") or die (mysql_error());
$count = mysql_num_rows($query);
if ($count >= 1) {
$error .= "<p>Username already taken.</p><br>";
}
if (!$error) {
mysql_query("INSERT INTO accounts (name, password) VALUES('$name', '$password')");
or die(mysql_error());
print "Account successfully created.";
} else {
echo $error;
}
}
?>-->
<br />
</p><center><h1>Create account</h1></center><hr/>
<center>
<form id= "create" name="create" method= "post" onsubmit="return validation()" action="" >
<table width= "310" border= "0" cellspacing= "" cellpadding= "0">
<tr>
<td><b>Username:</b></td>
<td><input type= "text" name="name" id="name" maxlength=12/></td>
<tr><td><div class="validation">Min 4 - Max 12 characters. No special characters. No spaces.</div></td></tr>
</tr>
<tr>
<td><b>Password:</b></td>
<td><label>
<input type="password" name="password" id="password" maxlength=12/>
<tr><td><div class="validation">Min 6 - Max 12 characters. No special characters. No spaces.</div></td></tr>
</label></td>
</tr>
<tr>
<td><b>Repeat password:</b></td>
<td><label>
<input type="password" name="password2" id="password2" maxlength=12/>
</label></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" id="Submit" value="Create account" /></td>
</tr>
</table>
<hr/>
</form>
</center>
</script>
</body>
</html>