duanlao6573 2018-07-26 10:00
浏览 41

执行PHP脚本后重新路由问题

I have a contactform that is built using php.

My domain is bestsellerprime.com

After the script executes, supposedly sending any email to info@bestsellerprime.com the page should reoute back to the homepage (index.html) but I get any error. The error says:

"This page isn’t working bestsellerprime.com is currently unable to handle this request. HTTP ERROR 500"

How do I resolve this, here is the code:

<div class="form">
                <form id="email-form" name="email-form" data-name="Email Form" class="form" method="post" action="contactform.php"><label for="name">Name:</label><input type="text" class="input" maxlength="256" name="name" data-name="Name" placeholder="Enter your name" id="name"><label for="email-3">Email Address:</label><input type="email" class="input" maxlength="256" name="email" data-name="email" placeholder="Enter your email" id="email-3" required=""><label for="question">Question:</label><input type="text" class="input" maxlength="256" name="question" data-name="question" placeholder="Enter your question" id="question" required=""><input type="submit" value="Submit" data-wait="Please wait..." class="contact-submit-button button" name="submit"></form>
                <div class="form-done">
                    <div>Thank you! Your submission has been received!</div>
                </div>
                <div class="form-fail">
                    <div>Oops! Something went wrong while submitting the form.</div>
                </div>
            </div>

PHP:

<?php

if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $mailFrom = $_POST['email'];
    $question = $_POST['question'];

    $mailTo = "info@bestsellerprime.com";
    $headers "From: ".mailFrom;
    $txt = "You have received an e-mail from ".$name.".

".$message;

    mail($mailTo, $mailFrom, $txt, $headers);   
    header("Location: index.html")
}

Any help is greatly appreciated.

  • 写回答

1条回答 默认 最新

  • douguxun6866 2018-07-26 10:03
    关注

    There are some syntax errors in the code.

    = missing and mailFrom should be $mailFrom in following line:

    $headers "From: ".mailFrom;
    

    Semi-colon missing in end of this line:

    header("Location: index.html")
    

    Correct code:

    <?php
    if (isset($_POST['submit'])) {
        $name = $_POST['name'];
        $mailFrom = $_POST['email'];
        $question = $_POST['question'];
    
        $mailTo = "info@bestsellerprime.com";
        $headers = "From: " . $mailFrom;
        $txt = "You have received an e-mail from " . $name . ".
    
    " . $message;
    
        mail($mailTo, $mailFrom, $txt, $headers);
        header("Location: index.html");
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据