我创建了一个联系页面,但是当我通过向网站的电子邮件地址(gmail 地址)发送电子邮件来测试它时,它显示一个白色页面这是我的联系表单的 php 代码<?phpif (isset ($_POST['submit'])) { $name = $_POST ['name']; $mailFrom = $_POST ['email']; $message = $_POST ['message'];$mailto = "lawsafrica@gmail.com";$headers = "From: ".$mailFrom;$txt = "You have received an e-mail from ".$name.".\n\n".$message;mail($mailTo, $txt, $headers);header ("Location: Contact.html?mailsend"); }这是我的 html 代码 (contact.html) <section class="box1"> <h2>Contact us</h2> <div class="lines"></div> <form class="contact-form" action="contactform.php" method= "POST"> <input type= "text" class= "contact-form-text" placeholder="Your name" required> <input type= "Email" class= "contact-form-text" placeholder="Your email"required> <textarea class="contact-form-text" placeholder="Your message"required></textarea> <input type="submit" class="contact-form-btn"value="Send"> </form></section><section class= "box2"> <h3>Didn't find what you are looking for?</h3> <div class="lines"></div> <form class="contact-form" action="contactform.php" method= "POST" > <input type= "text" name= "name" class= "contact-form-text" placeholder="Your name"required> <input type= "Email" name= "email" class= "contact-form-text" placeholder="Your email"required> <textarea class="contact-form-text" name= "message" placeholder="Type what are you looking for"required></textarea> <input type="submit" name= "submit" class="contact-form-btn"value="Send"> </form></section><section class= "box3"> <h4>Become a contributor</h4> <div class="lines"></div> <form class="contact-form" action="uploads.php" method= "POST" enctype= "multipart/form-data"> <input type= "file" class= "contact-form-text" > <button type="submit" class="contact-form-btn" name= "submit">Upload</button> </form></section>
1 回答
德玛西亚99
TA贡献1770条经验 获得超3个赞
发生这种情况是因为您忘记提供提交按钮的名称,contact.html并且contactform.php它只会检查名称为“提交”的发布事件isset ($_POST['submit'])
<section class="box1">
<h2>Contact us</h2>
<div class="lines"></div>
<form class="contact-form" action="contactform.php" method= "POST">
<input type= "text" class= "contact-form-text" placeholder="Your name" required>
<input type= "Email" class= "contact-form-text" placeholder="Your email"required>
<textarea class="contact-form-text" placeholder="Your message"required></textarea>
<input type="submit" name="submit" class="contact-form-btn"value="Send">
</form>
</section>
- 1 回答
- 0 关注
- 90 浏览
添加回答
举报
0/150
提交
取消