PHP Contact Form重定向到php / mail.php

时间:2016-06-14 19:23:48

标签: php contact-form

this page

底部有联系表格

当您点击“提交”时,该页面会转到../php/mail.php并且不会发送电子邮件。

表格

<form action="php/mail.php" method="POST">
    <p>Name</p> <input type="text" class="u-full-width" name="name" required/>
    <p>Email</p> <input type="text" class="u-full-width" name="email" required/>
    <p>Phone Number</p> <input type="text" class="u-full-width" name="number" required>
    <p>Number Of Guests</p>
    <select name="guests" size="1">
        <option value="Option1">1</option>
        <option value="Option2">2</option>
        <option value="Option3">3</option>
        <option value="Option4">4+</option>
    </select>
    <p>Bottle Service</p>
    <select name="bottleservice" size="1">
        <option value="Option1">No</option>
        <option value="Option2">Yes</option>
     </select>
     <p>Event Date</p>
     <select name="date" size="1">
         <option value="Option1">June 18th</option>
     </select><br />
     <input type="submit" value="Submit"><br /><input type="reset" value="Clear"/>
</form>

PHP:

$event = $POST['date'];
$name = $_POST['name'];
$email = $_POST['email'];
$guests = $POST['guests'];
$bottleservice = $POST['bottleservice'];
$formcontent="From: $name \n Event: $date";
$recipient = "taylor.cooney@vegastudios.ca";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";

1 个答案:

答案 0 :(得分:1)

当您提交联系表单时,页面会重定向到http://vegastudios.ca/staging/Skeleton-2.0.4/events/php/mail.php,但是,我相信您的mail.php位于http://vegastudios.ca/staging/Skeleton-2.0.4/php/mail.php。所以你只需要将动作改为

<form action="../php/mail.php" method="POST">