Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
两个PHP邮件表单问题_Php_Forms_Requiredfieldvalidator - Fatal编程技术网

两个PHP邮件表单问题

两个PHP邮件表单问题,php,forms,requiredfieldvalidator,Php,Forms,Requiredfieldvalidator,我有这个PHP表单邮件程序的问题 我有这个网站 这是表单的HTML… <form method="post" id="submitform" action="submitemail.php" > <input type="text" style="height: 40px;" class="formstyle" title="Your Name" placeholder="First & Last

我有这个PHP表单邮件程序的问题

我有这个网站

这是表单的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>
    $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>

这是PHP…

            <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>
    $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>
$emailerror.=“您的预订表已提交。您很快就会收到我们的通知。”;
//现在发送询价单
$timestamp=日期(“fj,Y,g:ia”);
$messageproper=“\n\n”。
“姓名:”。
ucwords($\u POST['name'])。
“\n”。
“电话:”。
ucwords(“电话”)。
“\n”。
“电子邮件:”。
$\u POST['email']。
“\n”。
“确认电子邮件:”。
$\u POST['email\u confirm']。
“\n”。
“低预算:”。
$\u POST[“低价”]。
“\n”。
“高预算:”。
$\邮政['高价']。
“\n”。
“场馆名称:”。
$\u POST['vention\u name']。
“\n”。
“活动容量:”。
$\u POST[“事件容量”]。
“\n”。
“事件描述:”。
$\u POST['message']。
“\n”。
“\n\n”;
$messageproper=修剪(条纹斜杠($messageproper));
邮件($mailto、$subject、$messageproperty,“发件人:\”$vname\“\n收件人:\”.ucwords($\u POST['first\u name'])。“\”\nX Mailer:PHP/”.phpversion());
}
?>
这个表格还可以

  • 我正试图显示一条信息,上面写着,“您的预订 表单已提交。您将很快收到我们的回复。“,但是 它不起作用了

  • 另一个问题是我想让每个字段都成为必填字段。我 找到有关使电子邮件字段成为必填字段的信息,但未找到 其他的

  • 你能帮忙吗?

    
    
    <?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>
    
    
    

    不客气。

    如果只发送电子邮件,是否希望邮件显示?是的。提交时,消息会显示…那么,问题出在哪里。只要执行
    if(mail())
    然后显示一些不正确的内容,如果
    mail
    功能出现错误,则消息仍将显示。正确的答案是
    if(mail(…)echo“Your booking…”
    这不是他的问题。他想要的是在发送电子邮件后回显成功消息。我的代码就是这样做的。易于理解的这与电子邮件错误无关,我只是复制并粘贴了他的电子邮件格式。不,即使邮件没有发送,你的代码也会显示邮件。如果
    mail
    收到错误,则消息尚未发送,您将显示消息。检查评论