okay i figured out how to make the comment/name fields sticky, but i can't figure out how to make the radio buttons and check box sticky... can someone help me!!!
also...
i need this to check for missing fields and to display an error message when there is something not filled out... i thought i did this as well, but its not working...
can someone help me out?? thanks so much
<?php
// process the email
if (array_key_exists('Register', $_POST)) {
$to = 'xxxxxxxxxx';
$subject = 'Feedback from Registration';
// list expected fields
$expected = array('firstName', 'lastName', 'email', 'topics', 'deliveryfrequency',
'language', 'instructions');
// set required fields
$required = array('firstName', 'lastName', 'email', 'topics', 'deliveryfrequency',
'language');
// create empty array for any missing fields
$missing = array();
// process the $POST variables
foreach ($POST as $key => $value) {
// assign to temporary variable and strip whitespace if not an array
$temp = is_array($value) ? $value : trim($value);
// if empty and required, add to $missing array
if (empty($temp) && in_array($key, $required)) {
array_push($missing, $key);
}
// otherwise, assign to a variable of the same name as $key
elseif (in_array($key, $expected)) {
${$key} = $temp;
}
}
// go ahead only if all required fields OK
if (empty($missing))
{
// build the message
$message = "Name: $lastName\n\n";
$message .= "Email: $email\n\n";
$message .= "Comments: $instructions";
} else {
//prepare an error message
echo ('Please make sure that all *required fields are filled.');
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Processing Exercise</title>
</head>
<body>
<div id="header">
<h3> Form Processing Exercise </h3>
<hr>
</div>
<div id="registrationForm">
<!-- Message to the user-->
<b>Free Newsletter Registration</b><br>
<p>Please fill out the form and submit to register for free subscription.</p>
<!-- End of message -->
<div>
<form action="" method="post">
<label for="firstName">First Name:* <?php
if (isset($missing) && in_array('firstName', $missing)) { ?>
<span class="warning">Please enter your name</span><?php } ?>
</label>
<input name="firstName" id="firstName" type="text" class="formbox"
<?php if (isset($missing)) {
echo 'value="'.htmlentities($_POST['firstName']).'"';} ?>
/>
<br>
<label for="lastName">Last Name:* <?php
if (isset($missing) && in_array('lastName', $missing)) { ?>
<span class="warning">Please enter your name</span><?php } ?>
</label>
<input name="lastName" id="lastName" type="text" class="formbox"
<?php if (isset($missing)) {
echo 'value="'.htmlentities($_POST['lastName']).'"';} ?>
/>
<br>
<label for="email">Email:* <?php
if (isset($missing) && in_array('email', $missing)) { ?>
<span class="warning">Please enter your email address</span><?php } ?>
</label>
<input name="email" id="email" type="text" class="formbox"
<?php if (isset($missing)) {
echo 'value="'.htmlentities($_POST['email']).'"';} ?>
/>
<br>
<fieldset style = "width: 30%" id="topics">
<b>Topics:*</b><br>
Cooking <br>
<input type="checkbox" name="interests" value="Cooking" />
<br />
Gardening<br>
<input type="checkbox" name="interets" value="Gardening" />
<br />
Coding <br>
<input type="checkbox" name="interests" value="Coding" /><br>
</div>
</fieldset>
<br>
<form action="<?php echo $SERVER['php_SELF'];?>" method="post">
<p><input type="text" name="deliveryfrequency" value="<?php echo $POST['deliveryfrequency'];?>"/>
<p>Daily<input type="radio" name="delivery" value="daily"<? if ($POST['arad'] == 1) echo " checked";?>>
Weekly<input type="radio" name="delivery" value="weekly"<? if ($POST['arad'] == 2) echo " checked";?>>
Monthly<input type="radio" name="delivery" value="monthly"<? if ($_POST['arad'] == 3) echo " checked";?>>
<p>
</form>
<p><B>Language:*<b><br>
<SELECT name = "language">
<Option value = 1>English</Option>
<Option value = 2>Spanish</Option>
<Option value = 3>French</Option>
</Select><br>
<label for="instructions">Special Instructions: <br>
<?php
if (isset($missing) && in_array('instructions', $missing)) { ?>
<span class="warning">Please enter your comments</span><?php } ?>
</label>
<textarea name="instructions" id="instructions" cols="60" rows="8"><?php
if (isset($missing)) {
echo htmlentities($_POST['instructions']);
} ?></textarea>
<br>
<input type="Submit" name="Register" value="Register">
</form>
</div>
</body>
</html>