联系表格谢谢您回到页首 [英] Contact Form Thank You Top of Page
问题描述
我有一个功能完善的联系表单,并在提交时显示Thank You消息。唯一的问题是,感谢消息显示在表单上方,因此当用户单击该消息时发送消息并不明显。
我的表格在这里:
http://impressify.co/business-writing.php
我如何做到这一点,我点击提交按钮页面滚动到顶部,然后显示联系消息?我不想让用户明白邮件发送成功。
我的代码如下:
<? $($ _
$ b if($ _ SERVER ['REQUEST_METHOD'] ==POST){
$ allowedExts = array(gif,jpeg, jpg,png,doc,pdf,docx,
jpg,docx,odt,txt,msg,csv ,ppt,pptx,xml,
,tar,m4a,mp3,wav,wma,mp4,mov,flv,可执行程序);
$ b $($ i = 1; $ i <= 2; $ i ++){
$ temp = explode(。,$ _FILES [attach。 $ i] [ 名称]);
$ extension = end($ temp);
if(in_array($ extension,$ allowedExts)){
move_uploaded_file($ _ FILES [attach。$ i] [tmp_name],
upload /。$ _ POST [ 名字] - $ _ FILES [ 附加 $ i] [ 名称]);
}
}
$ to ='myemail@gmail.com';
$ subject ='Business Writing Request from
'。$ _ POST [firstname]。$ _ POST [email];
$ message = $ _POST [message]。\\\
\\\
\\\
附件:。$ _ FILES [attach1]
[firstname]。。$ _FILES [attach2] [firstname]。
。$ _ FILES [attach3] [firstname];
$ firstname = $ _ REQUEST ['firstname'];
$ companyname = $ _ REQUEST ['companyname'];
$ email = $ _ REQUEST ['email']; $(b
$ b)if(($ firstname ==)||($ email ==)||($ message ==))
{
echo < strong>< p class = greentip>一个名字,信息和电子邮件需要
,请填写< a href = / business-writing.php>表单< / a>
再次< / p>< /强><峰; br>中;
}
else {
mail(n.dumanov@gmail.com,$ subject,$ message,$ email);
echo< strong>< p>您的免费咨询请求已收到!
在接下来的24小时内预计会有详细回复!< / p>< / strong>;
}
}
?>
< form action =method =postenctype =multipart / form-data>
< div class =row uniform 50%>
< div class =6u 12u(mobilep)>
< input name =firstnametype =textvalue =placeholder =Name>< br>
< / div>
< div class =6u 12u(mobilep)>
< / div>
< div>
< input name =emailtype =textvalue =placeholder =Email>< br>
< / div>
< / div>
< div class =row uniform 50%>
< div class =12u>
< / div>
< / div>
< br>< br>
< center>< input class type =submitvalue =submit>< / center> <峰; br>
< / form>
为什么不设置表单的ID ,然后直接到表单动作中的锚:
< form action =#my-formmethod = postenctype =multipart / form-dataid =my-form>
这将基本上提交您的表单并重新加载您的网址:
http://impressify.co/business-writing.php#my -form
它应该能够让你直接到达你想要的位置,它可以在我设置的简单测试中运行。
或者我想不是将表单的ID设置为my-form
,你可以设置你的< p>
标记,其中包含您的确认消息,如form-confirmation-message
,并设置您的行为形式为 action =#form-confirmation-message
这可能是最好的选择,带给你正确的信息,而不是形式,这正好接近你的信息。
I have a contact form that is fully functional and displays a "Thank You" message when submitting. The only problem is that the thank you message displays above the form so it's not obvious that the message was sent when the user clicks it.
My form is here:
http://impressify.co/business-writing.php
How do I make it so that when I click the submit button the page scrolls to the top and then displays the contact message? I wan't to make it obvious to the user that the message was sent successfully.
My code is below:
<?
if($_SERVER['REQUEST_METHOD'] == "POST") {
$allowedExts = array("gif", "jpeg", "jpg", "png", "doc", "pdf", "docx",
"jpg", "docx", "odt", "txt", "msg", "csv", "pps", "ppt", "pptx", "xml",
"tar", "m4a", "mp3", "wav", "wma", "mp4", "mov", "flv", "exe");
for ($i = 1; $i <= 2; $i++) {
$temp = explode(".", $_FILES["attach".$i]["name"]);
$extension = end($temp);
if (in_array($extension, $allowedExts)) {
move_uploaded_file($_FILES["attach".$i]["tmp_name"],
"upload/" .$_POST["firstname"]."-".$_FILES["attach".$i]["name"]);
}
}
$to = 'myemail@gmail.com';
$subject = 'Business Writing Request from
'.$_POST["firstname"].$_POST["email"];
$message = $_POST["message"]."\n\n\n Attachments: ".$_FILES["attach1"]
["firstname"]." ".$_FILES["attach2"]["firstname"]."
".$_FILES["attach3"]["firstname"];
$firstname=$_REQUEST['firstname'];
$companyname=$_REQUEST['companyname'];
$email=$_REQUEST['email'];
if (($firstname=="")||($email=="")||($message==""))
{
echo "<strong><p class =greentip>A first name, message, and email are
required, please fill <a href=/business-writing.php>the form</a>
again.</p></strong><br>";
}
else{
mail("n.dumanov@gmail.com", $subject, $message, $email);
echo "<strong><p>Your free consultation request has been received!
Expect a detailed response within the next 24 hours!</p></strong>";
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<div class="row uniform 50%">
<div class="6u 12u(mobilep)">
<input name="firstname" type="text" value="" placeholder="Name"><br>
</div>
<div class="6u 12u(mobilep)">
<input name="companyname" type="text" value="" placeholder="Company Name"><br>
</div>
<div>
<input name="email" type="text" value="" placeholder="Email"><br>
</div>
</div>
<div class="row uniform 50%">
<div class="12u">
<textarea name="message" rows="7" cols="30" placeholder="Give us a general sense of the kind of writing you or your ogranization needs."></textarea><br>
</div>
</div>
<br><br>
<center><input class type="submit" value="submit"></center> <br>
</form>
Why don't you set the ID of your form, and then direct to the anchor in your form action:
<form action="#my-form" method="post" enctype="multipart/form-data" id="my-form">
This will basically submit your form and reload your URL as:
http://impressify.co/business-writing.php#my-form
And it should bring you right down to where you want to be, it worked in a simple test I set up.
Or I suppose instead of setting the ID of the form to "my-form"
you could could set the ID of your <p>
tag that contains your confirmation message to something like "form-confirmation-message"
and set the action of your form to action="#form-confirmation-message"
This would probably be the best option as it would bring you right to your message instead of the form, which is just close to your message.
这篇关于联系表格谢谢您回到页首的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!