我在电子邮件联系表单上点击提交时会显示代码

时间:2015-03-18 21:39:52

标签: php html

我想让简单的联系表格起作用。当它点击提交发送电子邮件时,它只显示下一页的代码。所以我认为它不是表单页面而是send_form_email.php。请帮我把这段代码搞定,我不知道我在这里缺少什么。我已经尝试编辑代码工作,但它没有改变输出。我把它放在pastebin而不是在这里,因为我无法正确格式化代码。 http://pastebin.com/VFN7epGx

if(
    !isset($_POST['first_name']) ||
    !isset($_POST['last_name']) ||
    !isset($_POST['email']) ||
    !isset($_POST['telephone']) ||
    !isset($_POST['comments'])
) {
    died('We are sorry, but there appears to be a problem with the form you  submitted.');      

}

$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required

//我认为这可能与此相关

2 个答案:

答案 0 :(得分:0)

添加else语句并使用echo而不是dead可能会有所帮助:     if(!isset($ _ POST [' first_name'])||

!isset($_POST['last_name']) ||

!isset($_POST['email']) ||

!isset($_POST['telephone']) ||

!isset($_POST['comments'])) {
echo('We are sorry, but there appears to be a problem with the form you submitted.');

} else {



$first_name = $_POST['first_name']; // required

$last_name = $_POST['last_name']; // required

$email_from = $_POST['email']; // required

$telephone = $_POST['telephone']; // not required

$comments = $_POST['comments']; // required
}

抱歉fpr格式不好,我正在手机上。明天我会在我的电脑上查看这个,如果你还没有解决它。

答案 1 :(得分:0)

我无法访问pastebin,因为它似乎已被删除,但是会亲自编写它 - 并添加preg_replace()代码来清理输入。确保没有任何意外关闭php标记,并且脚本标记之外没有JavaScript。

     if( !isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) ||  !isset($_POST['comments'])) {
     echo 'We are sorry, but there appears to be a problem with the form you submitted.';
     }else{
     $first_name = $_POST['first_name']; // required
     $last_name = $_POST['last_name']; // required
     $email_from = $_POST['email']; // required
     $telephone = $_POST['telephone']; // not required
     $comments = $_POST['comments']; // required
     }

我喜欢@ T.Somers为清理他的输入而做的事情 PHP Code losing its values when I hit submit

这很好地解释了preg_replace

Regular Expression clean method PHP来自@CodeCaster

相关问题