有没有办法解决php空白页错误?

我创建了一个联系页面,但是当我通过向网站的电子邮件地址(gmail 地址)发送电子邮件来测试它时,它显示一个白色页面


这是我的联系表单的 php 代码


<?php

if (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>


喵喵时光机
浏览 91回答 1
1回答

德玛西亚99

发生这种情况是因为您忘记提供提交按钮的名称,contact.html并且contactform.php它只会检查名称为“提交”的发布事件isset ($_POST['submit'])&nbsp;<section class="box1">&nbsp; &nbsp; <h2>Contact us</h2>&nbsp; &nbsp; <div class="lines"></div>&nbsp; &nbsp;<form class="contact-form" action="contactform.php" method= "POST">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <input type= "text" class= "contact-form-text" placeholder="Your name" required>&nbsp; &nbsp; &nbsp; &nbsp; <input type= "Email" class= "contact-form-text" placeholder="Your email"required>&nbsp; &nbsp; &nbsp; &nbsp; <textarea class="contact-form-text" placeholder="Your message"required></textarea>&nbsp; &nbsp; &nbsp; &nbsp; <input type="submit" name="submit" class="contact-form-btn"value="Send">&nbsp; &nbsp; </form></section>
打开App,查看更多内容
随时随地看视频慕课网APP