我有这个表格:
<form action="../index_success.php" method="post" id="sendEmail" class="email">
<h3 class="register2">Newsletter Signup:</h3>
<ul class="forms email">
<li class="name">
<label for="yourName">Name: </label>
<input type="text" name="yourName" class="info" id="yourName" value="<?php echo $_POST['yourName']; ?>" /><br />
</li>
<li class="city"><label for="yourCity">City: </label>
<input type="text" name="yourCity" class="info" id="yourCity" value="<?php echo $_POST['yourCity']; ?>" /><br />
</li>
//This is where I need help with the check box code
<li class="classes"><label for="classInterest">Interested in classes?: </label>
<input type="checkbox" name="classInterest" class="info" id="classInterest" value="Yes" /><br />
</li>
<li class="email">
<label for="emailFrom">Email: </label>
<input type="text" name="emailFrom" class="info" id="emailFrom" value="<?php echo $_POST['emailFrom']; ?>" />
<?php if(isset($emailFromError)) echo '<span class="error">'.$emailFromError.'</span>';
?>
</li>
<li class="buttons email">
<button type="submit" id="submit">Send</button>
<input type="hidden" name="submitted" id="submitted" value="true" />
</li>
</ul>
</form>
这是通过电子邮件发送给用户的。我不知道如何添加上面的复选框,因此如果选中该框,用户会看到“是”:
<?php
$mailTo = 'xxx@xxx.com'; // This is the hardcoded Recipient Address
$mailSubject = 'Subject'; // This is the hardcoded Subject
$mailFrom = $_POST['emailFrom'];
$yourName = $_POST['yourName'];
$yourCity = $_POST['yourCity'];
$classInterest = $_POST['classInterest']; //This is the code for the checkbox
$mailHeader = "From: {$mailFrom}";
$mailBody = "Name = {$yourName} City = {$yourCity} Class interest = {$classInterest}";
mail( $mailTo , $mailSubject , $mailBody , $mailHeader );
基本上,我需要的是(psudocode):
if ($classInterest == "yes") {
$classInterest = "Interested in Classes in ".$yourCity;
}
else {
...
}