lupe
-
Posts
4 -
Joined
-
Last visited
Posts posted by lupe
-
-
<p><label>Email Address: <input type="email" name = "email" size ="40" maxlength="60"></label></p>
Forgot to put "text" in input type.
Same with comments, in the php-form. Thanks. -
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple HTML Form</title>
<style type="text/css">
label {
font-weight: bold;
color: #300ACC;
}
</style>
</head>
<body>
<!-- Script 2.1 -->
<form action ="handle_form.php" method ="post">
<fieldset><legend>Enter your information in the form below:</legend>
<p><lable>Name: <input type="text" name ="name" size ="20" maxlength ="40"></lable></p>
<p><label>Email Address: <input type="email" name = "email" size ="40" maxlength="60"></label></p>
<p><label for="gender">Gender: </label><input type="radio" name ="gender" value="M"> Male <input type="radio" name="gender" value="F"> Female</p>
<p><label>Age:
<select name="age">
<option value="0-29">Under 30</option>
<option value="30-60">Between 30 and 60</option>
<option value="60+">Over 60</option>
</select></label></p>
<p><label>Comments: <textarea name="comments" rows="3" cols="40"></textarea></label></p>
</fieldset>
<p align="center"><input type="submit" name="submit" value="Submit My Information"></p>
</form>
</body>
</html> -
Im keep getting this error, anyone have any pro tips?( Notice: Undefined variable: email in C:\xampp\htdocs\gp\book\handle_form.php on line 52<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Feedback</title>
<style type="text/css" media="all">
.error {
font-weight: bold;
color: #C00;
}
</style>
</head>
<body>
<?php // Validate Name
if (!empty($_REQUEST['name'])) {
$name = $_REQUEST['name'];
} else {
$name = NULL;
echo '<p class="error">You forgot to enter your name!</p>';
} // Validate Email
if (!empty($_REQUEST['email'])) {
$mail = $_REQUEST['email'];
} else {
$email = NULL;
echo '<p class="error">You forgot to enter your email address!</p>';
} // Validate Comments
if (!empty($_REQUEST['comments'])) {
$mail = $_REQUEST['comments'];
} else {
$comments = NULL;
echo '<p class="error">You forgot to enter your comments!</p>';
}
// Validate the gender
if (isset($_REQUEST['gender'])) {
$gender = $_REQUEST['gender'];
if ($gender == 'M') {
$greeting = '<p><strong>Good day, Sir!</strong></p>';
} elseif ($gender == 'F') {
$greeting = '<p><strong>Good day, Madam!</strong></p>';
} else { $gender = NULL;
echo '<p class="error">Gender should be either "M" or "F"!</p>'; }
} else {
$gender = NULL;
echo '<p class="error">You forgot to select your gender!</p>';
}
// Print message indicating validation results
if ($name && $email && $gender && $comments){
echo "<p>Thank you, <strong> $name</strong>, for the following comments:<br>
<pre>$comments</pre></p> <p>We will reply to you at <em>$email</em>.</p>\n";
echo $greeting; }
else {
echo '<p class="error">Please go back and fill out the form again.</p>';
}
?>
</body>
</html>
Stuck At This Point.
in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
Posted
Everything is good now.