已关闭。此问题需要details or clarity。当前不接受答案。
**想要改进此问题?**添加详细信息并通过editing this post阐明问题。
昨天关门了。
这篇文章是昨天编辑并提交审查的。
Improve this question
我试图创建一个表单,用户将填写该表单,填写后,当用户单击提交,我会自动接收用户数据,用户会收到确认邮件告诉有关申请成功。
我试过用几个php脚本来实现这个功能,但我从当前的脚本中得到的结果是,它重新加载了页面,并且没有向我发送任何数据和确认邮件。
拜托,我真的需要帮助。
下面是我的表单域的代码。
<section class="contact_section layout_padding-top">
<div class="container-fluid">
<div class="row">
<div class=" col-md-6">
<div id="map" class="h-100 w-100 ">
</div>
</div>
<div class=" col-md-6 contact_form-container">
<div class="contact_box">
<form action="" method="post">
<p>Fill Application Form</p>
<div>
<input type="text" placeholder=" Full Name" name="name" required>
</div>
<div >
<input type="tel" placeholder=" Phone Number" name="phone" >
</div>
<div>
<input type="email" placeholder=" Email" name="email">
</div>
<div >
<input type="text" placeholder="AFull Name" name="Aname" >
</div>
<select required name="rank" class="form-control" class="text_input" size="1" id="5">
<option value="">Select Rank</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
<br />
<div>
<label class="w3-label w3-text-black">Tell us</label>
<textarea placeholder="Enter text here" class="w3-input w3-border" rows="7" required name="comment"></textarea>
</div>
<div>
<p class="success"> <?php echo $success; ?></p>
<p class="failed"> <?php echo $failed; ?></p>
</div>
<div>
<button type="submit" id="bub" value="SUMBIT" >Submit</button>
</div>
</form>
</div>
</div>
</div>
这是php脚本,我真的需要帮助,谢谢。
if(!empty($_POST["submit"])) {
$mailto = "myemail@domain.com"; //My email address
//getting customer data
$name = $_POST["name"]; //getting customer name
$fromEmail = $_POST["email"]; //getting customer email
$phone = $_POST["tel"]; //getting customer Phome number
$Aname = $_POST["text"];
$rank = $_POST["text"];
$subject = $_POST["subject"]; //getting subject line from client
$subject2 = "Confirmation: Message was submitted successfully | Department"; // For customer confirmation
//Email body I will receive
$message = "Cleint Name: " . $name . "\n"
. "Phone Number: " . $phone . "\n\n"
. "Email Address: " . $email . "\n\n"
. "Army Name: " . $Aname . "\n\n"
. "Rank: " . $rank . "\n\n"
. "Client Message: " . "\n" . $_POST['message'];
//Message for client confirmation
$message2 = "Hi" . $name . "\n"
. "Thank you for applying for your vacation. We will get back to you shortly!" . "\n\n"
. "You submitted the following message: " . "\n" . $_POST['message'] . "\n\n"
. "Regards," . "\n" . "- HMA WebDesign";
//Email headers
$headers = "From: " . $fromEmail; // Client email, I will receive
$headers2 = "From: " . $mailto; // This will receive client
//PHP mailer function
$result1 = mail($mailto, $subject, $message, $headers); // This email sent to My address
$result2 = mail($fromEmail, $subject2, $message2, $headers2); //This confirmation email to client
//Checking if Mails sent successfully
if ($result1 && $result2) {
$success = "Your Message was sent Successfully!";
} else {
$failed = "Sorry! Message was not sent, Try again Later.";
}
}
?>
1条答案
按热度按时间hgqdbh6s1#
在你的提交按钮中添加名字
因为您的脚本检查
if (!empty($_POST["submit"]))