两个PHP邮件表单问题

时间:2013-08-11 23:14:15

标签: php forms requiredfieldvalidator

我遇到了这个PHP Form Mailer的问题...

我有网站here

这是表单的HTML ...

            <form method="post" id="submitform" action="submitemail.php" >
                        <input type="text" style="height: 40px;" class="formstyle" title="Your Name" placeholder="First & Last Name" name="name" />
                        <input type="tel" style="height: 40px;" class="formstyle" title="Phone Number" placeholder="###-###-####" name="phone" />       
                        <input type="email" style="height: 40px;" class="formstyle" title="Email" placeholder="Email Address" name="email" />
                        <input type="email" style="height: 40px;" class="formstyle" title="Confirm Email" placeholder="Confirm Email" name="email_confirm" />
                        <input type="text" style="height: 40px;" class="formstyle" title="Ticket Price Low" placeholder="$ Amount" name="low_price" />
                        <input type="text" style="height: 40px;" class="formstyle" title="Ticket Price High" placeholder="$ Amount" name="high_price" />
                        <input type="text" style="height: 40px;" class="formstyle" title="Venue Name" placeholder="Where will it be?" name="venue_name" />
                        <input type="text" style="height: 40px;" class="formstyle" title="Event Capacity" placeholder="# of people attending" name="event_capacity" />

                        <textarea name="message" style="height: 90px;" title="Event Description" placeholder="Please describe anything about this event we should know."></textarea>
                        <input class="formstyletwo" type="submit" value="Send">  
            </form>

这是PHP ...

    $emailerror .= "Your booking form has been submitted. You will hear from us shortly.";

    // NOW SEND THE ENQUIRY
    $timestamp = date("F j, Y, g:ia");

    $messageproper ="\n\n" .
        "Name: " .
        ucwords($_POST['name']) .
        "\n" .
        "Phone: " .
        ucwords('phone') .
        "\n" .
        "Email: " .
        $_POST['email'] .
        "\n" .
        "Confirmed Email: " .
        $_POST['email_confirm'] .
        "\n" .
        "Low Budget: " .
        $_POST['low_price'] .
        "\n" .
        "Hight Budget: " .
        $_POST['high_price'] .
        "\n" .
        "Venue Name: " .
        $_POST['venue_name'] .
        "\n" .
        "Event Capacity: " .
        $_POST['event_capacity'] .
        "\n" .
        "Event Description: " .
        $_POST['message'] .
        "\n" .
        "\n\n" ;

        $messageproper = trim(stripslashes($messageproper));
        mail($mailto, $subject, $messageproper, "From: \"$vname\" <".$_POST['e_mail'].">\nReply-To: \"".ucwords($_POST['first_name'])."\" <".$_POST['e_mail'].">\nX-Mailer: PHP/" . phpversion() );
}
?>

<div id='emailerror'>
    <ul>
        <? echo $emailerror; ?>
    </ul>

表单正常。

  1. 我正在尝试显示一条消息:“ 您的预订 表格已提交。您很快就会收到我们的回复。 “,但是 它不起作用。

  2. 另一个问题是我想让每个字段成为必填字段。一世 找到了有关制作电子邮件字段的信息,但没有 其他

  3. 你能帮忙吗?

1 个答案:

答案 0 :(得分:-1)

<?php
if(isset($_POST["submit_button_name"])){
mail($mailto, $subject, $messageproper, "From: \"$vname\" <".$_POST['e_mail'].">\nReply-To: \"".ucwords($_POST['first_name'])."\" <".$_POST['e_mail'].">\nX-Mailer: PHP/" . phpversion() );
echo "Your booking form has been submitted. You will hear from us shortly.";
}
else{
echo "An error occured.";
}
?>

要制作所需的表单,只需在输入中放置。

<input type="text" name="myfield" placeholder="Example" required>

欢迎你。