Halløjsa derude.
jeg har lavet mig en opret form på mit site, og selv koden efter er der ingen problemer med, den smider brugerens info ind i min database.
Men jeg kunne godt tænke mig at det hele kørte på min index.php , har prøvet if($_POST('formnavn') {} men den er ligeglad.
i kan lige få min kode, paster bare formen + validering koden, som ikke virker.
<form method="post" name="register">
<table width="160px" border="0">
<tr>
<td style=" text-align:center;">
<p><b> Username </b></p>
</td>
</tr>
<tr>
<td>
<input type="text" name="username" class="form" />
</td>
</tr>
<tr>
<td style=" text-align:center;">
<p><b> Password </b></p>
</td>
</tr>
<tr>
<td>
<input type="password" name="password" class="form" />
</td>
</tr>
<tr>
<td style=" text-align:center;">
<p><b> Re-enter Password </b></p>
</td>
</tr>
<tr>
<td>
<input type="password" name="re-password" class="form" />
</td>
</tr>
<tr>
<td style=" text-align:center;">
<p><b> Email Address </b></p>
</td>
</tr>
<tr>
<td>
<input type="text" name="email" class="form" />
</td>
</tr>
<tr>
<td style=" text-align:center;">
<p><b> Age </b></p>
</td>
</tr>
<tr>
<td>
<input type="text" name="age" class="form" />
</td>
</tr>
<tr>
<td style="text-align:center">
<input type="submit" value="" class="submitbut" />
</td>
</tr>
</table>
</form>
<?php }
if($_POST['register']) {
$username = $_POST['username'];
$password = $_POST['password'];
$repassword = $_POST['re-password'];
$email = $_POST['email'];
$age = $_POST['age'];
if($password != $repassword) {
echo "Entered passwords is not identical";
header("location: index.php?ps=register");
exit();
}
$valUsername = mysql_num_rows(mysql_query("SELECT * FROM users WHERE username = '$username'"));
if($valUsername == 1) {
echo "Entered username is already taken";
header("location: index.php?ps=register");
exit();
}
$valEmail = mysql_num_rows(mysql_query("SELECT * FROM users WHERE email = '$email'"));
if($valEmail == 1) {
echo "Entered email is already in use";
header("location: index.php?ps=register");
exit();
}
if($age < 16 ) {
echo "Users of Paradise Undone, have to be aleast 16";
header("location: index.php?ps=register");
exit();
}
// Hvis der ikke er nogen problemer, smider vi brugeren i systemet.
mysql_query("INSERT INTO users (username, password, email, age) VALUES ( '$username', SHA1('$password'), '$email', '$age')") or die(mysql_error());
echo "Your user have been created, and ready for login entry";
$oprettet = true;
}
Jeg ved ikke om det er mig der er uvidenede mener bare det er sådan man får den til at trigger, håber i kan hjælpe mig.