Php 当我点击电子邮件联系人表单上的submit时,代码显示

Php 当我点击电子邮件联系人表单上的submit时,代码显示,php,html,Php,Html,我正在努力让我的简单联系方式发挥作用。当点击submit发送电子邮件时,它只显示下一页的代码。所以我认为这不是表单页面,而是send_form_email.php。请帮助我让这个代码工作,我不知道我在这里错过了什么。我尝试过编辑代码以使其正常工作,但它并没有改变输出。我把它放在pastebin而不是这里,因为我无法使代码正确格式化 //我认为这可能与添加else语句和使用echo而不是dead有关,可能会有所帮助: 如果(!isset($\u POST['first\u name']))|| 抱

我正在努力让我的简单联系方式发挥作用。当点击submit发送电子邮件时,它只显示下一页的代码。所以我认为这不是表单页面,而是send_form_email.php。请帮助我让这个代码工作,我不知道我在这里错过了什么。我尝试过编辑代码以使其正常工作,但它并没有改变输出。我把它放在pastebin而不是这里,因为我无法使代码正确格式化


//我认为这可能与添加else语句和使用echo而不是dead有关,可能会有所帮助: 如果(!isset($\u POST['first\u name']))||


抱歉,fpr格式不正确,我在手机上。如果您还没有修复,明天我会在我的电脑上查看此问题。

我无法获取粘贴箱,因为它似乎已被删除,但我会亲自这样写-并添加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为清理他在网站上的输入所做的工作

这很好地解释了preg_替换


通过@CodeCaster

我刚刚复制了您的代码并在本地主机上运行。它适用于以下值:first\u name=John last\u name=Doe email=test@example.com电话=00011222333 comments=我是一条评论!如果文件显示为纯文本,则可能是php未正确配置。您确认其配置了吗?@Marc这是我可能使用的版本吗?你说配置正确是什么意思?我的xampp正在运行,我已经在本地主机上测试了其他php文件,如果这是你的意思的话。它在echo$Error之后显示代码。谢谢,我仍然在显示代码字符串,它一直这样显示
!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
}
     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
     }