指示PHP

时间:2016-02-20 15:03:23

标签: php

我正在尝试创建一个过程表单的PHP文件,该文件指示处理时所需的字段。我的代码是:

<html>
    <head>
        <style type="text/css">
            .error{color: #FF0000;}
        </style>
    </head>
    <body>
    <?php
    if(isset($_POST['fullname']) && $_POST['fullname'] != "") {
        $fullname = $_POST['fullname'];
    }
    if(isset($_POST['email']) && $_POST['email'] != "") {
        $email = $_POST['email'];
    }
    if(isset($_POST['feedback']) && $_POST['feedback'] != "") {
        $text= $_POST['feedback'];
    }

    $nameErr = $emailErr = "";
    $name = $email = "";

    if ($_SERVER["REQUEST_METHOD"] == POST) {
        if (empty($_POST["fullname"])){
            $nameErr = "Name is required";
        } else {
            $name = test_input($_POST["fullname"]);
        }
        if (empty($_POST["email"])) {
            $emailErr = "Email is required";
        } else {
            $email = test_input($_POST["email"]);
        }
    }
    ?>
        <h1>Customer Feedback</h1>
        <p1>Please tell us what you think</p1><br><br>
        <form method='POST' action='<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>' >
            <p1>Your name:</p1><br>
            <input type="text" name="fullname" value="<?php echo $fullname; ?>"><br><br>
            <p1>Your email address:</p1><br>
            <input type="text" name="email" value="<?php echo $email; ?>"><br><br>
            <p1>Your feedback:</p1><br>
            <textarea rows="5"  cols="50" name="feedback"><?php echo $text;?></textarea><br><br>
            <input type="submit" Value="Send Feedback"><br><br>
            <?php
                error_reporting(E_ALL);


                $name = $_POST['fullname'];
                $email = $_POST['email'];
                $feed = $_POST['feedback'];

                if (empty($name)) 
                {
                    echo "Please enter your name, email and feedback.";
                }
                if (empty($email)) 
                {
                    echo "Please enter your email and feedback.";
                }
                if (empty($feed))
                {
                    echo "Please enter feedback.";
                }
                if (!empty($name) && !empty($email) && !empty($feed))
                {
                    echo "You have inserted the correct data";
                }
            ?>
        </form>
    </body>
</html>

然而,当我在Chrome上运行它时,我收到服务器错误500,说

  

检索process_4.php时遇到网站并出错。它可能已关闭以进行维护或配置不正确。

我在这一点上做出的其他PHP文件都运行正常,我不知道为什么不这样做。

0 个答案:

没有答案