gpt4 book ai didi

php - 联系表 谢谢 页面顶部

转载 作者:行者123 更新时间:2023-11-28 01:19:47 26 4
gpt4 key购买 nike

我有一个功能齐全的联系表单,在提交时会显示“谢谢”消息。唯一的问题是感谢消息显示在表单上方,因此当用户单击它时,消息是否已发送并不明显。

我的表格在这里:

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,然后直接指向表单操作中的 anchor :

<form action="#my-form" method="post" enctype="multipart/form-data" id="my-form">

这基本上会提交您的表单并重新加载您的 URL 为:

http://impressify.co/business-writing.php#my-form

它应该会把你带到你想去的地方,它在我设置的一个简单测试中起作用了。

或者我想不是将表单的 ID 设置为 "my-form"你可以设置你的 ID <p>包含您的确认消息的标签,类似于 "form-confirmation-message"并将表单的操作设置为 action="#form-confirmation-message"

这可能是最好的选择,因为它会让您直接看到您的消息,而不是表格,它就在您的消息旁边。

关于php - 联系表 谢谢 页面顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34346550/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com