0

我在使用这个 PHP Form Mailer 时遇到问题...

这里有网站。

这是表单的 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. 另一个问题是我想让每个字段都成为必填字段。我找到了有关使电子邮件字段成为必需的信息,但没有找到其他信息。

你能帮我吗?

4

1 回答 1

-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.";
}
?>

要使表单成为必需,只需在输入中放置 required 。

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

别客气。

于 2014-06-23T08:43:52.500 回答