php 复选框没想,PHP复选框 - 返回'是'而不是1如何?

我有一个带复选框的简单联系表单,一旦有效并提交,我会回复表单的结果。我希望复选框项目在选中时返回YES,如果为空则返回NO。

这是我的片段:

$subject = "Website Contact Form Enquiry";

//If the form is submitted

if(isset($_POST['submit'])) {

//Check to make sure that the name field is not empty

if(trim($_POST['contactname']) == '') {

$hasError = true;

} else {

$name = trim($_POST['contactname']);

}

//Check to make sure sure that a valid email address is submitted

if(trim($_POST['email']) == '') {

$hasError = true;

} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {

$hasError = true;

} else {

$email = trim($_POST['email']);

}

//Check to make sure comments were entered

if(trim($_POST['message']) == '') {

$hasError = true;

} else {

if(function_exists('stripslashes')) {

$comments = stripslashes(trim($_POST['message']));

} else {

$comments = trim($_POST['message']);

}

}

if(isset($_POST['tour']) &&

$_POST['tour'] == 'yes')

{

$tour = true;

}

else

{

$tour = false;

}

//If there is no error, send the email

if(!isset($hasError)) {

$emailTo = 'info@bgv.co.za'; //Put your own email address here

$body = "Name: $name \n\nEmail: $email \n\nComments:\n $comments";

$headers = 'From: My Site ' . "\r\n" . 'Reply-To: ' . $email;

mail($emailTo, $subject, $body, $headers);

$emailSent = true;

}

}继承人回声

Name:

Email:

Message:

Tour:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值