应用表单后不会执行PHP脚本(浏览器仅显示部分代码)

应用表单后不会执行PHP脚本(浏览器仅显示部分代码),php,Php,我正在做一个简单的脚本,应该是在申请表格后发送电子邮件。我使用XAMPP服务器在本地主机上工作。我已经成功地配置了“sendmail”用于从本地主机发送电子邮件,并且通过一个只包含邮件功能的测试简单脚本发送电子邮件。当我填写链接到发送电子邮件脚本的表单时,问题就出现了:当我提交表单时,浏览器只显示部分php代码。PHPMailer包也存在同样的情况。我能在这里做什么 所有代码和截图均附呈 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transi

我正在做一个简单的脚本,应该是在申请表格后发送电子邮件。我使用XAMPP服务器在本地主机上工作。我已经成功地配置了“sendmail”用于从本地主机发送电子邮件,并且通过一个只包含邮件功能的测试简单脚本发送电子邮件。当我填写链接到发送电子邮件脚本的表单时,问题就出现了:当我提交表单时,浏览器只显示部分php代码。PHPMailer包也存在同样的情况。我能在这里做什么

所有代码和截图均附呈

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Aliens Abducted Me - Report an Abduction</title>
  <link rel="stylesheet" type="text/css" href="style.css" />
 </head>
 <body>
  <h2>Aliens Abducted Me - Report an Abduction</h2>

  <p>Share your story of alien abduction:</p>
  <form method="post" action="report.php">
    <label for="firstname">First name:</label>
    <input type="text" id="firstname" name="firstname" /><br />
    <label for="lastname">Last name:</label>
    <input type="text" id="lastname" name="lastname" /><br />
    <label for="email">What is your email address?</label>
    <input type="text" id="email" name="email" /><br />
    <label for="whenithappened">When did it happen?</label>
    <input type="text" id="whenithappened" name="whenithappened" /><br />
    <label for="howlong">How long were you gone?</label>
    <input type="text" id="howlong" name="howlong" /><br />
    <label for="howmany">How many did you see?</label>
    <input type="text" id="howmany" name="howmany" /><br />
    <label for="aliendescription">Describe them:</label>
    <input type="text" id="aliendescription" name="aliendescription"    size="32" /><br />
    <label for="whattheydid">What did they do to you?</label>
    <input type="text" id="whattheydid" name="whattheydid" size="32" /><br />
    <label for="fangspotted">Have you seen my dog Fang?</label>
     Yes <input id="fangspotted" name="fangspotted" type="radio" value="yes" />
     No <input id="fangspotted" name="fangspotted" type="radio" value="no"   /><br />
    <img src="fang.jpg" width="100" height="175" alt="My abducted dog Fang." /><br />
    <label for="other">Anything else you want to add?</label>
    <textarea id="other" name="other"></textarea><br />
    <input type="submit" value="Report Abduction" name="submit" />
  </form>
 </body>
</html>


<html>
<head>
 <title>Alien abduction report - aliens abducted me</title>
</head>

<body>
<h3>Aliens abducted me: my repory about abduction</h3>

<?php

    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);

    $full_name = $_POST['firstname'] . $_POST['lastname'];
    $description = $_POST['aliendescription'];
    $when_it_happened = $_POST['whenithappened'];
    $how_long = $_POST['howlong'];
    $how_many = $_POST['howmany'];
    $fang_spotted = $_POST['fangspotted'];
    $email = $_POST['email'];
    $what_they_did = $_POST['whattheydid'];
    $comments = $_POST['other'];


    echo 'Name: ' .  $full_name . '</br>';
    echo 'They ' . $what_they_did . 'whith you' . '</br>';
    echo 'It happens ' . $when_it_happened . '</br>';
    echo 'Thank you for sharing your information</br>';
    echo 'You were abducted  ' . $when_it_happened . '</br>';
    echo 'You were there for  ' . $how_long . '</br>';
    echo 'Did you see Fang?  ' . $fang_spotted . '</br>';
    echo 'Your email is:  ' . $email . '</br>';
    echo 'They are:   ' . $description . '</br>';
    echo 'Additional information:  ' . $comments;


    $msg = "$full_name was abducted for $how_long \n" .
        "It happened $when_it_happened, they were $description \n" .
        "There were $how_many aliens \n" .
        "Fang spotted $fang_spotted \n" .
        "They did $what_they_did \n" .
        "Email of abducted person $email \n" .
        "Additioanal information $comments";
    $subject = 'Abduction form report';

    mail($email, $subject, $msg, 'From: abduction form');

?>
</body>
</html>

外星人绑架了我-报告一起绑架案
外星人绑架了我-报告一起绑架案
分享你关于外星人绑架的故事:

名字:
姓氏:
你的电子邮件地址是什么?
什么时候发生的?
你离开多久了?
你看到多少?
描述它们:
他们对你做了什么?
你看见我的狗方了吗? 对 否

还有什么要补充的吗?
外星人绑架报告-外星人绑架了我 外星人绑架了我:我关于绑架的报道
您需要通过web服务器访问脚本,因此地址应为
http://localhost/report.php
而非
file:///...
它以这种方式工作得很好,我在运行脚本本身时没有遇到任何问题。当我尝试运行链接到脚本的html表单时,问题出现了。