简体   繁体   中英

why does this php contact form just download contact.php?

i'm a total n00b when it comes to PHP (and arguably, web development in general :/), but i've taken a look at a ton of examples, comparing my code, and i just can't figure it out. basically all thats happening is the contact.php file is just getting downloaded to my computer. ugh. also, this client did not ask for any field validation, which is why theres none there. help!!

heres my html-

<form action="contact.php" method="post">
                <fieldset>
                  <legend><strong>Get A Quote!</strong>
                  </legend>
                   Call me at 555-555-5555, or email me at <a href="">email@emaiul.com</a>, or use the form below.<br /><br />
                    <div class="clearfix">

                        <div class="input">
                          <input style="width:370px; height:35px; font-size:14px;" value="Name"  name="name" size="50"  type="text">
                        </div>
                    </div><!-- /clearfix -->

                    <div class="clearfix">
                        <div class="input">
                         <input style="width:370px; height:35px; font-size:14px;" value="Email"  name="email" size="50"  type="text">
                        </div>
                    </div><!-- /clearfix -->

                    <div class="clearfix">
                        <div class="input">
                          <input style="width:370px; height:35px; font-size:14px;" value="Phone"  name="phone" size="50"  type="text">
                        </div>
                    </div><!-- /clearfix -->

                    <div class="clearfix">
                        <div class="input">
                         <textarea style="width:370px; height:55px; font-size:14px;"  name="message" size="50"  type="text">Message</textarea>
                        </div>
                    </div><!-- /clearfix -->
                </fieldset>
                  <button type="submit" name="saveForm" style="background-image: url(static/img/btn-submit.png); width:150px; height:37px;"></button>
              </form>        

and the php-

<?php
if(isset($_POST['saveForm'])) {
$to = "steven@urethrafranklin.org";
$subject = "Inquiry from website";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

mail($to, $subject, $body);
} else {
echo "Sorry, something went wrong. Please email me at user@user.com.";
}
?>

Ah, you guys are all right.

tail -f /var/log/mail.log

was helpful.
And I am now using validate.js . Thanks guys!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM