Hej.
Jeg sidder og er ved at lave en brugerregistrering. Den virker indtil videre www.caketown.dk/hp/index.php?side=registrer
det der mangler lige nu er noget kode der siger at når en bruger skal oprettes, så må det valgte brugernavn ikke være optaget
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if($_POST["submit1"]) {
$host = "database";
$dbuser = "user";
$dbpass = "pass";
$dbname = "name";
$connection = mysql_connect($host,$dbuser,$dbpass);
$db = mysql_select_db($dbname,$connection);
$name = $_POST["username"];
$pass = $_POST["password"];
$pass2 = $_POST["pass1"];
$email = $_POST["email"];
$ip = $_SERVER[REMOTE_ADDR];
//if else (else if)
if(strlen($name) == 0 || strlen($pass) == 0 || strlen($email) == 0) {
echo "Please fill in all the required fields.";
}
elseif($pass != $pass2) {
echo "The two passwords do not match.";
}
else {
$connection = mysql_connect($host,$dbuser,$dbpass);
$db = mysql_select_db($dbname,$connection);
$write = mysql_query("INSERT INTO user (username, password, email, ip) VALUES ('$name', '$pass', '$email', '$ip')") OR DIE (mysql_error());
$result = mysql_query($write);
echo "Registrering færdig!";
}
}
?>
<form action="" method="POST">
<table style="border: 0px;">
<tr>
<td><a>Brugernavn:</a></td>
<td><input name="username" type="text" /></td>
</tr>
<tr>
<td><a>Kodeord:</a></td>
<td><input name="password" type="password" /></td>
</tr>
<tr>
<td><a>Kodeord<br />igen:</a></td>
<td><input name="pass1" type="password" /></td>
</tr>
<tr>
<td><a>E-mail:</a></td>
<td><input name="email" type="text" /></td>
</tr>
<tr>
<td><input name="submit1" type="submit" value="Opret" /></td>
</tr>
</table>
</form>
</body>
</html>
Nogen forslag?