联系表 谢谢 页面顶部
Contact Form Thank You Top of Page
我有一个功能齐全的联系表,在提交时会显示一条 "Thank You" 消息。唯一的问题是感谢消息显示在表单上方,因此当用户单击它时,消息是否已发送并不明显。
我的表格在这里:
http://impressify.co/business-writing.php
如何才能让当我点击提交按钮时页面滚动到顶部然后显示联系信息?我不想让用户知道消息已成功发送。
我的代码如下:
<?
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>
为什么不设置表单的 ID,然后直接指向表单操作中的锚点:
<form action="#my-form" method="post" enctype="multipart/form-data" id="my-form">
这基本上会提交您的表单并重新加载您的 URL 为:
http://impressify.co/business-writing.php#my-form
它应该会把你带到你想去的地方,它在我设置的一个简单测试中起作用了。
或者我想您可以将包含确认消息的 <p>
标签的 ID 设置为 "form-confirmation-message"
之类的内容,而不是将表单的 ID 设置为 "my-form"
并且将表单的操作设置为 action="#form-confirmation-message"
这可能是最好的选择,因为它会让您直接看到您的消息,而不是表格,它就在您的消息附近。
我有一个功能齐全的联系表,在提交时会显示一条 "Thank You" 消息。唯一的问题是感谢消息显示在表单上方,因此当用户单击它时,消息是否已发送并不明显。
我的表格在这里:
http://impressify.co/business-writing.php
如何才能让当我点击提交按钮时页面滚动到顶部然后显示联系信息?我不想让用户知道消息已成功发送。
我的代码如下:
<?
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>
为什么不设置表单的 ID,然后直接指向表单操作中的锚点:
<form action="#my-form" method="post" enctype="multipart/form-data" id="my-form">
这基本上会提交您的表单并重新加载您的 URL 为:
http://impressify.co/business-writing.php#my-form
它应该会把你带到你想去的地方,它在我设置的一个简单测试中起作用了。
或者我想您可以将包含确认消息的 <p>
标签的 ID 设置为 "form-confirmation-message"
之类的内容,而不是将表单的 ID 设置为 "my-form"
并且将表单的操作设置为 action="#form-confirmation-message"
这可能是最好的选择,因为它会让您直接看到您的消息,而不是表格,它就在您的消息附近。