代码像html一样工作,但是当集成php时就中断了


Code works as html, but breaks when php is integrated

我有一个联系人表单,显示良好的html代码,但当我试图整合我的php代码没有显示。这是我在php中尝试做的第一件事,所以我不知道问题是什么。其他简单的测试php文件在我的服务器上工作。

链接到文件:https://www.dropbox.com/s/8voii6525qyc1j4/contactForm1.php

    <?php
    error_reporting(E_ALL);

    if($_POST['submit']){
    $to = "he1sdit@gmail.com";
    $name = trim($_POST['name']);
    $company = trim($_POST['company']);
    $address = trim($_POST['address']);
    $address2 = trim($_POST['address2']);
    $city = trim($_POST['city']);
    $state = trim($_POST['state']);
    $zip = trim($_POST['zip']);
    $phone = trim($_POST['phone']);
    $fax = trim($_POST['fax']);
    $email = trim($_POST['email']);
    $subject = trim($_POST['subject']);
    $comments = trim($_POST['comments']);
    $messages ="Name: $mail 'r'n Company: $company 'r'n Address: $address 'r'n Address 2 : $address2 'r'n City: $city 'r'n State: $state 'r'n Zip/Postal Code $zip 'r'n Telephone: $phone 'r'n Fax: $fax 'r'n Email Address: $email 'r'n Comments: $comments";
    $headers = "From:" . $name;
    $mailsent = mail($to,$subject,$messages,$headers);
    if($mailsent){
        $sent=true;
    }
    else{
        $sent=false;
    }

    ?>
<!DOCTYPE html>
<html>
    <head>
            <title>Jay Car Construction</title>
        <link href="style.css" rel="stylesheet" type="text/css">
    </head>
    <body>
        <div class="container_16">
            <header>
                <div class="grid_7 brand"><img src="images/Logo.png"></div>
                <div class="grid_4 getStarted">
                    <h3>
                        <a href="/contact.html"> Click Here To Start Your Next Project!</a>
                    </h3>
                </div>
            </header>
            <h1>
                <div class="grid_16 subbrand">Jay-Car Construction Co., INC.</div>
                    <h2>
                        <div class="grid_16 subhead">Est. 1967</div>
                    </h2>
            </h1>
            <nav>
            <div>
                <ul>
                    <li><a href="/index.html">Home</a>
                    <li><a href="/projects.html">Projects</a>
                    <li><a href="/services.html">Services</a>
                    <li><a href="about.html">About Us</a>
                    <li class="finalNav"><a href="careers.html">Careers</a></li>
                </ul>
            </div>  
            </nav>
            <div class="grid_16 pageImage">
                <img src="images/projectsPage.png"
            </div>
            <div class="grid_16 topBanner">
                <img src="images/TopBanner1.png"/>
            </div>
            <div class="contact">
                <h3>
                    Please allow us to help you get your next project underway.  Submit your information below, and we will get back to you as soon as possible.
                </h3>
                <hr/>
                <?php if($sent == true){ ?>
                    <p>
                        Your message has been sent successfully.  We will respond as quickly as possible.
                    </p>
                <?php } if($sent==false){ ?>
                    <p>
                        We are unable to process your request at this time. Please try again later.
                    </p>
                    <?php } ?>

                <form name="contact_form" action="<php echo $_SERVER['PHP_SELF']; ?>" method="post">
                    <label for="name">Name:</label>
                    <input type="text" name="name"/>
                    <br/>
                    <label for="company">Company: </label>
                    <input type="text" name="company"/>
                    <br/>
                    <label for="address">Address:</label>
                    <input type="text" name="address"/>
                    <br/>
                    <label for="address2">Address Line 2:</label>
                    <input type="text" name="address2"/>
                    <br/>
                    <label for="city">City:</label>
                    <input type="text" name="city"/>
                    <br/>
                    <label for="state">State:</label>
                    <input type="text" name="state"/>
                    <br/>
                    <label for="zip">Zip/Postal Code:</label>
                    <input type="text" name="zip"/>
                    <br/>
                    <label for="phone">Telephone:</label>
                    <input type="text" name="phone"/>
                    <br/>
                    <label for="fax">Fax:</label>
                    <input type="text" name="fax"/>
                    <br/>
                    <label for="email">Email Address:</label>
                    <input type="email" name="email"/>
                    <br/>
                    <label for="subject">Subject:</label>
                    <input type="text" name="subject"/>
                    <br/>
                    <label for="comments">Comments:</label>
                    <textarea name="comments" cols="30" rows="5"></textarea>
                    <br/>
                    <div class="clear">
                    </div>
                    <hr/>
                    <input type="submit" value="Submit" style="border:outset; border-color:#FFF;"/>

                </form>
            </div>
            <div class="clear">
            </div>
            <div>
                <footer class="bottomBanner">
                    <ul class="grid_8">
                        <li><a href="/index.html">Home</li>
                        <li>|</li>
                        <li><a href="/projects.html">Projects</li>
                        <li>|</li>
                        <li><a href="/services.html">Services</li>
                        <li>|</li>
                        <li><a href="/about.html">About Us</li>
                        <li>|</li>
                        <li><a href="/careers.html">Careers</li>
                        <li>|</li>
                        <li><a href="/contact.html">Contact Us</li>
                    </ul>
                    <p class="grid_6">
                        &copy 2014 Jay-Car Construction Co., INC.
                    </p>
                </footer>
            </div>
        </div>
    </body>
</html>

您在第91行<?php和结束括号之间没有空格。

<?php } if($sent==false){ ?>