So all I have to do is enclose this block
$ip = getenv('REMOTE_ADDR');
$username = trim(mysql_real_escape_string($_POST['username']));
$password = sha1(trim(mysql_real_escape_string($_POST['password'])));
$email = trim(mysql_real_escape_string($_POST['email']));
$insert = "INSERT INTO members (ip, username, password, email, date_entered) VALUES ('$ip', '$username', '$password', '$email', NOW())";
if (@mysql_query ($insert)) {
echo 'Thanks for registering.';
} else {
echo 'There was a problem registering. Please try again.';
}
mysql_close();}
with
if ($problem == false) {}
Is it correct if I set $problem = false or does it actually have to be $problem == false? So in the //Is it empty? section should by $problem be $problem == true instead of $problem = true?
Thanks for the help it worked.
How can I use
if (empty ($_POST['username'])) {
$problem = TRUE;
echo 'Please enter a username.';
}
and echo out 'Please enter a username' next to
<label>Username</label><br/><input name="username" maxlength="20" />
It automatically echos when I go to the page if I try this:
<label>Username</label><br/><input name="username" maxlength="20" />
<?php if (empty ($_POST['username'])) {
$problem = TRUE;
echo 'Please enter a username.';
}
?>