PHP ver gevorderde |
|
Ok, heb ff je code is helemaal bekeken en denk dat ik de fout heb gevonden.
Je deed dit:
<form />
<input>
</form>
terwijl het zo is:
<form>
<input>
</form>
Heb ondertussen de rest van de code wat overzichtelijker gemaakt, en ben tot de conclusie gekomen dat 3 POST-variabelen niet meegestuurd worden.
Er staat in de commentaar bij welke.
<?php
include "include/config.php";
include "include/functions.php";
$ip = $_SERVER['REMOTE_ADDR'];
$date = date("d-m-Y H:i:s");
?>
<form action="register.php" method="post" name="register">
Username:<br />
<input type="text" name="username" maxlength="50" /><br />
Password:<br />
<input type="password" name="pass" maxlength="200" /><br />
Password [confirm]:<br />
<input type="password" name="cpass" maxlength="200" /><br />
Email:<br />
<input type="text" name="mail" maxlength="250" /><br />
Email [confirm]:<br />
<input type="text" name="cmail" maxlength="250" /><br />
Your IP:<br />
<input type="text" name="your_ip" value="<? print "$ip" ?>" disabled /><br />
Date/time:<br />
<input type="text" name="date/time" value="<? print "$date" ?>" disabled /><br />
<input type="submit" name="submit" value="Submit!" /><br />
</form>
<?php
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$pass = $_POST['pass'];
$cpass = $_POST['cpass'];
$mail = $_POST['mail'];
$cmail = $_POST['cmail'];
function check_mail($in)
{
$patroon = "/^([a-z0-9_-]+\.)*[a-z0-9_-]+@([a-z0-9_-]{2,}\.)+([a-z0-9_-]{2,})$/i";
return preg_match($patroon, $in);
}
$query = mysql_query("SELECT * FROM users") or die(mysql_error());
$check = mysql_num_rows($query);
$checkname = mysql_query("SELECT username FROM users WHERE username = '".$username."'") or die (mysql_error());
$checkname = mysql_num_rows($checkname);
$checkemail = mysql_query("SELECT mail FROM users WHERE mail = '".$mail."'") or die (mysql_error());
$checkemail = mysql_num_rows($checkemail);
$checkip = mysql_query("SELECT ip FROM users WHERE ip = '".$ip."'") or die (mysql_error());
$checkip = mysql_num_rows($checkip);
if(empty($username))
{
echo "You must fill in an username";
}
elseif(empty($pass))
{
echo "You have to fill in a password";
}
elseif(empty($cpass))
{
echo "You have to confirm your password";
}
elseif(!check_mail($_POST['mail']))
{
echo "You have to fill in an email address";
}
elseif(!check_mail($_POST['cmail']))
{
echo "You have to confirm your email address";
}
elseif($pass != $cpass)
{
echo "Your passwords must be the same";
}
elseif($username == $pass)
{
echo "For saftey can your username and password not be the same";
}
elseif($mail != $cmail)
{
echo "You have to fill in your email address twice";
}
elseif($checkemail > 0)
{
echo "That email address has already been used";
}
elseif($checkname > 0)
{
echo "That username has already been taken";
}
elseif($checkip > 0)
{
echo "Only 1 account per ip is allowed";
}
else
{
$pass = md5($pass);
if($check == 0)
{
mysql_query("
INSERT INTO `users`
(
id,
username,
pass,
ip,
mail,
activation,
date,
subtitle,
status
)
VALUES
(
'',
'".$username."',
'".$pass."',
'".$ip."',
'".$mail."',
'".$key."',
NOW(),
'Webmaster!',
'webmaster'
)
") or die(mysql_error());
echo "There is an email with activation on the way!";
}
else
{
mysql_query("
INSERT INTO `users`
(
id,
username,
pass,
ip,
mail,
activation,
date,
subtitle,
status
)
VALUES
(
'',
'".$username."',
'".$pass."',
'".$ip."',
'".$mail."',
'".$key."',
NOW(),
'Lid!',
'lid'
)
") or die(mysql_error());
echo "There is an email with activation on the way!";
$username = $_POST['username'];
$mail = $_POST['mail'];
$webmaster = $_POST['webmaster']; // Bestaat niet!!!
$webmaster_mail = $_POST['webmaster_mail']; // Bestaat niet!!!
$subject = $_POST['Complete registration']; // Bestaat niet!!!
$headers = "From: ".$webmaster." <".$webmaster_mail.">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$message = "You have registered on ".$url.". To confirm your registration, click the link below
".$url."leden/activeer.php?email=".$mail."&key=".$key."
If you haven't registered, just ignore this email, the account will be deleted in 48 hours.
";
mail($mail, $subject, $message, $headers);
}
}
}
?>
<?php include "include/config.php"; include "include/functions.php"; $ip = $_SERVER['REMOTE_ADDR']; $date = date("d-m-Y H:i:s"); ?> <form action="register.php" method="post" name="register"> Username:<br /> <input type="text" name="username" maxlength="50" /><br /> Password:<br /> <input type="password" name="pass" maxlength="200" /><br /> Password [confirm]:<br /> <input type="password" name="cpass" maxlength="200" /><br /> Email:<br /> <input type="text" name="mail" maxlength="250" /><br /> Email [confirm]:<br /> <input type="text" name="cmail" maxlength="250" /><br /> Your IP:<br /> <input type="text" name="your_ip" value=" <? print "$ip" ?>" disabled /><br /> Date/time:<br /> <input type="text" name="date/time" value=" <? print "$date" ?>" disabled /><br /> <input type="submit" name="submit" value="Submit!" /><br /> </form> <?php if(isset($_POST['submit'])) { $username = $_POST['username']; $pass = $_POST['pass']; $cpass = $_POST['cpass']; $mail = $_POST['mail']; $cmail = $_POST['cmail']; function check_mail($in) { $patroon = "/^([a-z0-9_-]+\.)*[a-z0-9_-]+@([a-z0-9_-]{2,}\.)+([a-z0-9_-]{2,})$/i"; } { echo "You must fill in an username"; } { echo "You have to fill in a password"; } { echo "You have to confirm your password"; } elseif(!check_mail($_POST['mail'])) { echo "You have to fill in an email address"; } elseif(!check_mail($_POST['cmail'])) { echo "You have to confirm your email address"; } elseif($pass != $cpass) { echo "Your passwords must be the same"; } elseif($username == $pass) { echo "For saftey can your username and password not be the same"; } elseif($mail != $cmail) { echo "You have to fill in your email address twice"; } elseif($checkemail > 0) { echo "That email address has already been used"; } elseif($checkname > 0) { echo "That username has already been taken"; } elseif($checkip > 0) { echo "Only 1 account per ip is allowed"; } else { if($check == 0) { INSERT INTO `users` ( id, username, pass, ip, mail, activation, date, subtitle, status ) VALUES ( '', '".$username."', '".$pass."', '".$ip."', '".$mail."', '".$key."', NOW(), 'Webmaster!', 'webmaster' ) echo "There is an email with activation on the way!"; } else { INSERT INTO `users` ( id, username, pass, ip, mail, activation, date, subtitle, status ) VALUES ( '', '".$username."', '".$pass."', '".$ip."', '".$mail."', '".$key."', NOW(), 'Lid!', 'lid' ) echo "There is an email with activation on the way!"; $username = $_POST['username']; $mail = $_POST['mail']; $webmaster = $_POST['webmaster']; // Bestaat niet!!! $webmaster_mail = $_POST['webmaster_mail']; // Bestaat niet!!! $subject = $_POST['Complete registration']; // Bestaat niet!!! $headers = "From: ".$webmaster." <".$webmaster_mail.">\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $message = "You have registered on ".$url.". To confirm your registration, click the link below ".$url."leden/activeer.php?email=".$mail."&key=".$key." If you haven't registered, just ignore this email, the account will be deleted in 48 hours. "; mail($mail, $subject, $message, $headers); } } } ?>
Dus ik vermoed dat het de html-code was ipv de php-code.
Trouwens, dat zwart kleurtje op RickyB zn naam, betekend dat dat hij verbannen is?
Murfy edit: inderdaad, goed gezien |