好。我不知道。我过去可以指向他们的后端表单,但现在他们告诉我我必须执行mail((函数。。。我在Dreamweaver中创建了这个表单,它看起来很棒。但仅此而已。我以为我把它绑定到了php文件,但当你点击提交时,它会打开一个新窗口,看起来它试图打开php,而不是用它把表单结果发送到我的电子邮件中。
链接到页面(我无法将代码带到过去而不出错(:http://rivieradecor.co/contact_riviera_decor.html
链接到php:http://rivieradecor.co/send_form_email.php
if(isset($_POST['email'](({
// EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "heather@thetrinitydesign.com"; $email_subject = "Contact Form From Website"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['phone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['name']; // required $last_name = $_POST['HaveyoueverhadCustomInteriorDesignworkbefore_0']; // required $email_from = $_POST['email']; // required $telephone = $_POST['BestContactTime']; // required $comments = $_POST['Areyoulookingfor_']; // not required $comments = $_POST['What room will be designing for']; // not required $comments = $_POST['color scheme']; // not required $comments = $_POST['StyleChoice']; // not required $comments = $_POST['FabricChoice']; // not required $comments = $_POST['Budget']; // not required $comments = $_POST['StyleChoice_1']; // not required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+'.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.'n'n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."'n"; $email_message .= "Last Name: ".clean_string($last_name)."'n"; $email_message .= "Email: ".clean_string($email_from)."'n"; $email_message .= "Telephone: ".clean_string($telephone)."'n"; $email_message .= "Comments: ".clean_string($comments)."'n"; // create email headers $headers = 'From: '.$email_from."'r'n". 'Reply-To: '.$email_from."'r'n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> <link href="riveria.css" rel="stylesheet" type="text/css"> <body class="headerlinks"> Thank you for contacting us. We will be in touch with you soon. <?php } ?>
The form begis like this:
<form action="send_form_email.php" method="get" enctype="multipart/form-data" name="Info Form" id="Info Form">
结尾是这样的:
您似乎发布了错误的表单,因为表单打开标记edit method="get"为method="post">
<form action="send_form_email.php" method="post" enctype="multipart/form-data" name="Info Form" id="Info Form">
还尝试将用户重定向到成功步骤页面
header('Location: thanks.html');
并尝试进行服务器端验证,以帮助用户从第一次填写您的表格,查看
对于电子邮件脚本,请检查这个简单的参考,它将帮助您CSS-TRICKS