Forum Moderators: coopster
Can someone look at my script and let me know where the error is. It was working. I deleted one of the brackets "}", and now it doesn't work. I can't remember which line I deleted it from.
<?php
// Check name and strip any slashes:
if (strlen($name) > 0) {
$name = stripslashes($name);
} else {
// If no name was entered...
$name = NULL;
echo '<p><b>You forgot to enter your name!</b></p>';
}
// Check $comments and strip any slashes:
if (strlen($comments) > 0) {
$comments = stripslashes($comments);
} else {
// If there are no comments...
$comments = NULL;
echo '<p><b>You forgot to enter your comments!</b></p>';
}
// Check $email:
if (!(strlen($email) > 0) ) {
$email = NULL;
echo '<p><b>You forgot to enter your email!</b></p>';
}
// Gender...
if (isset($gender)) {
if ($gender == 'M') {
$message = '<b><p>Good day, Sir!</p></b>';
} elseif ($gender == 'F') {
$message = '<b><p>Good day, Madam!</p></b>';
} else {
// If no gender was selected...
$gender = NULL;
echo '<p><b>You forgot to enter your gender!</b></p>';
}
// If everything was filled out, print the message.
if ($name && $comments && $email && $gender) {
echo "Thank you, <b>$name</b> for the following comments:<br /><tt>$comments</tt><p>We will reply to you at <i>$email</i>.</p>";
echo $message;
}
?>
<html>
<form action="" method="">
<fieldset>
<legend>Enter your information in the form below:</legend>
<p><b>Name:</b> <input type="text" name="name" size="20" maxlength="40" /></p>
<p><b>Email Address:</b> <input type="text" name=email" size="40" maxlength="60" /></p>
<p><b>Gender:</b> <input type="radio" name="gender" value="M" />Male <input type="radio" name="gender" value="F" />Female</p>
<p><b>Age:</b>
<select name="age">
<option value="0 - 30">Under 30</option>
<option value="30 - 60">Between 30 and 60</option>
<option value="60+">Over 60</option>
</select></p>
<p><b>Comments:</b>
<textarea name="comments" rows="3" cols="50"></textarea></p>
</fieldset>
<div align="center"><input type="submit" name="submit" value="Submit Information" />
</div>
</form>
isset() { didn't have it's closing bracket }
// Gender...
if (isset($gender)) {
if ($gender == 'M') {
$message = '<b><p>Good day, Sir!</p></b>';}
elseif ($gender == 'F') {
$message = '<b><p>Good day, Madam!</p></b>';
} else {
// If no gender was selected...
$gender = NULL;
echo '<p><b>You forgot to enter your gender!</b></p>';
}