PHP expert |
|
heb nu dus een script alleen hij zeikt altijd dat de email niet is ingevuld, zover ik kan zien zijn de namen etc. wel goed, maar mss doe ik iets verkeerd wat jullie wel zien 
ps: op regel 32 word er gekeke word of de email veld leeg is of niet 
<html>
<head>
<title>Register</title>
</head>
<body>
<form name="register" method="post" action="<?php $php_self ?>">
Username:<br />
<input name="username" type="text" id="username" <? if($_SESSION['auth']){ echo "disabled=disabled"; } ?>><br />
Password:<br />
<input name="password" type="password" id="password" <? if($_SESSION['auth']){ echo "disabled=disabled"; } ?>><br />
Password [check]:<br />
<input name="cpassword" type="password" id="cpassword" <? if($_SESSION['auth']){ echo "disabled=disabled"; } ?>><br />
Email:<br />
<input name="email" type="text" id="email"><br />
<input name="submit" type="submit" id="submit" value="Submit Registration" <? if($_SESSION['auth']){ echo "disabled=disabled"; } ?>>
<br /><br />
<?php
if(isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$cpassword = $_POST['cpassword'];
$email = $_POST['emai1'];
$ip = $_SERVER['REMOTE_ADDR'];
if(empty($username)) {
echo "You have to fill in an username";
}elseif (empty($password)) {
echo "You have to fill in a password";
}elseif (empty($cpassword)) {
echo "You have to confirm your password";
}elseif (empty($email)) {
echo "You have to fill in an email address";
}elseif($password != $cpassword) {
echo "passwords do not match";
}else{
$password = md5($password);
$checkname = mysql_query("SELECT username FROM users WHERE username='$username'");
$checkname= mysql_num_rows($checkname);
$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
$checkemail = mysql_num_rows($checkemail);
if ($checkemail>0) {
echo "That email address has already been used";
}elseif ($checkname>0) {
echo "That username has already been taken";
}else{
$username = htmlspecialchars($username);
$password = htmlspecialchars($password);
$email = htmlspecialchars($email);
$query = mysql_query("INSERT INTO users (username, password, email, ip) VALUES('$username','$password','$email','$ip')");
echo "You have successfully registered!";
echo "You can now login by clicking <a href='?pagina=login'>here</a>";
}
}
}
?>
</body>
</html>
<html> <head> <title>Register</title> </head> <body> <form name="register" method="post" action="<?php $php_self ?>"> Username:<br /> <input name="username" type="text" id="username" <? if($_SESSION['auth']){ echo "disabled=disabled"; } ?>><br /> Password:<br /> <input name="password" type="password" id="password" <? if($_SESSION['auth']){ echo "disabled=disabled"; } ?>><br /> Password [check]:<br /> <input name="cpassword" type="password" id="cpassword" <? if($_SESSION['auth']){ echo "disabled=disabled"; } ?>><br /> Email:<br /> <input name="email" type="text" id="email"><br /> <input name="submit" type="submit" id="submit" value="Submit Registration" <? if($_SESSION['auth']){ echo "disabled=disabled"; } ?>> <br /><br /> <?php if(isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; $cpassword = $_POST['cpassword']; $email = $_POST['emai1']; $ip = $_SERVER['REMOTE_ADDR']; echo "You have to fill in an username"; }elseif (empty($password)) { echo "You have to fill in a password"; }elseif (empty($cpassword)) { echo "You have to confirm your password"; }elseif (empty($email)) { echo "You have to fill in an email address"; }elseif($password != $cpassword) { echo "passwords do not match"; }else{ $password = md5($password); $checkname = mysql_query("SELECT username FROM users WHERE username='$username'"); $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'"); if ($checkemail>0) { echo "That email address has already been used"; }elseif ($checkname>0) { echo "That username has already been taken"; }else{ $query = mysql_query("INSERT INTO users (username, password, email, ip) VALUES('$username','$password','$email','$ip')"); echo "You have successfully registered!"; echo "You can now login by clicking <a href='?pagina=login'>here</a>"; } } } ?> </body> </html>
|