php复选框代码提交错误,PHP反馈表单复选框错误

好的,这里是我的联系表单的一个缩写版本的PHP,(复选框没有正确发送)

//please fill this in at least!

$myemail = "";

$title = "Feedback Form";

if(isset($_POST['submit'])) { //form has been submitted

//set variables with filters

$cont_name = filter_var($_POST['cont_name'], FILTER_SANITIZE_STRING);

$email = filter_var($_POST['cont_email'], FILTER_SANITIZE_STRING);

$phone = filter_var($_POST['cont_phone'], FILTER_SANITIZE_STRING);

$first_time = filter_var($_POST['first_time'], FILTER_SANITIZE_STRING);

$hear_about = filter_var($_POST['hear_about'], FILTER_SANITIZE_STRING);

function valid_email($str){

return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;}

$errors = 0; //by default there are no errors

$trimcont_name = trim($cont_name);

if(empty($trimcont_name)){

//the name field is empty

$errors = 1; //tips off the error messages below

$errorcont_name = "The name field is empty"; //this error is displayed next to the label

}

if(!valid_email($email)) {

//email is invalid or empty

$errors = 1;

$erroremail = "The email address was not valid";

}

$trimphone = trim($phone);

if(empty($trimphone)){

//the phone field is empty

$errors = 1;

$errorphone = "The phone field is empty";

}

$trimfirst_time = trim($first_time);

if(empty($trimfirst_time)){

//the first_time field is empty

$errors = 1;

$errorfirst_time = "This field is empty";

}

$trimhear_about = trim($hear_about);

if(empty($trimhear_about)){

//the hear_about field is empty

$errors = 1;

$errorhear_about = "This field is empty";

}

if($spam != "") {

//spam was filled in

$errors = 1;

$errorspam = "The Spam box was filled in";

}

if($errors == 0) {

$sendto = $myemail;

$message = <<

DETAILS

Name: $cont_name

Email: $email

Phone: $phone

Was this the first time you have been to us?

$first_time

How did you hear about us?

$hear_about

DATA;

$headers = 'From: ' . $name . '';

if(mail($sendto, $title, $message, $headers)) {

//this is where it sends, using the php mail function

$success = true;

//set all the variables to blank to prevent re-submitting.

$cont_name = "";

$email = "";

$phone = "";

$hear_about = "";

$first_time = "";

} else {

$success = false;

}

} else {

$success = false;

}

}

?>并且该区域无法正常工作

How did you hear about us? <?php echo $errorhear_about; ?>

Web
Newspaper
Radio
Driving Past
Referal
Other

目前只有在选择了多个变量时才会显示其中一个变量。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值