在填写所需字段后,联系表格应该处理用户输入的信息并以电子邮件格式发送给接收者,在这种情况下接收者是网站所有者。但是在页面自动刷新后没有任何反应。任何帮助,将不胜感激。我已经包含了下面的代码,其中还嵌入了PHP。
<!DOCTYPE html>
<html lang="en">
<head**strong text**>
<meta charset="utf-8">
<title>Contact - Dream Occasions</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/contact.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="navbar-wrapper">
<div class="container">
<nav class="navbar navbar-inverse navbar-static-top">
<div class="navbar-header">
<a class="navbar-brand">Dream Occasions</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Home</a></li>
<li><a href="services.html">Services</a></li>
<li><a href="gallery.html">Gallery</a></li>
<li class="active"><a href="contact.html" style="background-color:#3366ff">Contact</a></li>
<div class="header-icons">
<li><a href="https://www.facebook.com/irelanddreamoccasions/"><i class="fa fa-facebook"style="font-size: 0.90em;"></i></a></li>
<li><a href="#"><i class="fa fa-instagram"style="font-size: 0.90em; padding-left:20px;"></i></a></li>
<li><a href="https://www.pinterest.com/sconboy2002/?eq=suzanne%20conboy&etslf=10321"><i class="fa fa-pinterest"style="font-size: 0.90em; padding-left:20px;"></i></a></li>
</ul>
</li>
</ul>
</div>
</div>
</div><!-- /container -->
</div>
<div class="contact">
<form id="contact" action="" method="post">
<h3>Get in Touch</h3>
<h4>Contact us for a free consultation.</h4>
<fieldset>
<input placeholder="Your name" type="text" name="Name" tabindex="1" required autofocus>
</fieldset>
<fieldset>
<input placeholder="Your Email Address" type="Email" name="Email" tabindex="2" required>
</fieldset>
<fieldset>
<input placeholder="Your Phone Number (optional)" type="Tel" name="Tel" tabindex="3">
</fieldset>
<fieldset>
<textarea placeholder="Type your message here...." name="Message" tabindex="5" required></textarea>
</fieldset>
<fieldset>
<button name="submit" type="submit" id="contact-submit" data-submit="...Sending">Submit</button>
</fieldset>
</form>
</div>
<?php
if(isset($_POST['Submit'])){
$to = "dreamoccasions@eircom.net"; // this is your Email address
$from = $_POST['Email']; // this is the sender's Email address
$name = $_POST['Name'];
$tel = $_POST['Tel'];
$submit = $_POST['submit'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $name . " wrote the following:" . "\n\n" . $_POST['Message'];
$message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['Message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2);
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
}
?>
<footer class="footer-distributed">
<div class="footer-left">
<p class="footer-links">
<a href="index.html">Home</a>
<a href="services.html">Services</a>
<a href="gallery.html">Gallery</a>
<a href="contact.html">Contact</a>
</p>
</div>
<div class="footer-center">
<span>Contact us</span>
<div>
<i class="fa fa-map-marker"></i>
<p>Edgeworthstown, Co.Longford</p>
</div>
<div>
<i class="fa fa-phone"></i>
<p>Telephone Us At - 0868558521</p>
</div>
<div>
<i class="fa fa-envelope"></i>
<p>dreamoccasions@eircom.net</p>
</div>
</div>
<div class="footer-right">
<p class="footer-company-about">
<span>Connect with us</span>
<p>On our numerous social medias to keep up to date.</p>
</p>
<div class="footer-icons">
<a href="https://www.facebook.com/irelanddreamoccasions/"><i class="fa fa-facebook"></i></a>
<a href="#"><i class="fa fa-instagram"></i></a>
<a href="https://www.pinterest.com/sconboy2002/?eq=suzanne%20conboy&etslf=10321"><i class="fa fa-pinterest"></i></a>
</div>
</div>
<hr>
<p class="footer-company-name"><span>Dream Occasions © 2017. All Rights Reserved.</span>
<span>Site Developed By Joel Conboy</span>
<?php echo date("Y"); ?>
</p>
</footer>
</body>
</html>
答案 0 :(得分:1)
您有<button name="submit"
,但您正在查看if(isset($_POST['Submit'])){
。你的案件不匹配。请拨打您的按钮Submit
,它应该有效。