这里是我使用的形式:为什么没有被张贴在电子邮件我<select>值
<form action="scripts/contactscript.php" method="post" id="contactform">
<ol>
<li>
<label for="name">Your Name <span class="red">*</span></label>
<input id="name" name="name" class="text" />
</li>
<li>
<label for="email">Your email <span class="red">*</span></label>
<input id="email" name="email" class="text" />
</li>
<li>
<label for="interested">Interested In <span class="red">*</span></label>
<select id="interested" name="interested">
<option value="">-- Please Select --</option>
<option value="GeneralInformation">General Information</option>
<option value="PurchasingABike">Purchasing A Bike</option>
</select>
</li>
<li>
<label for="message">Message <span class="red">*</span></label>
<textarea id="message" name="message" rows="6" cols="50"></textarea>
</li>
<li class="buttons">
<input type="image" name="imageField" id="imageField" src="images/send.gif" class="send" />
<div class="clr"></div>
</li>
</ol>
</form>
,这里是它被张贴到脚本:
<?php
if(!$_POST) exit;
$email = $_POST['email'];
//$error[] = preg_match('/\b[A-Z0-9._%-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)){
$error.="Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array ('name','email','message','interested');
$required = array('name','email','message');
$your_email = "[email protected]";
$email_subject = "Little Bike Riders Message: ".$_POST['subject'];
$email_content = "New message:\n\n";
foreach($values as $key => $value){
if(in_array($value,$required)){
if(empty($_POST[$value])) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n\n" ;
}
if(@mail($your_email,$email_subject,$email_content)) {
echo 'Message sent!';
} else {
echo 'ERROR!';
}
}
?>
这里是所示在当发送的电子邮件:
新信息:
名称:乔恩·哈丁
电子邮件:[email protected]
消息:测试
感兴趣:
谢谢Michael! – 2012-03-03 18:54:35
'$ email_content'是什么样的?当'var_dump($ _ POST)''时,你看到'interested'的值吗? – 2012-03-03 18:58:09
我在文章 – 2012-03-03 19:01:56