简体   繁体   English

提交表格的空白页

[英]Blank page on submitting form

I have this code on the page "GetUsers.php"我在“GetUsers.php”页面上有这个代码

    <form action="actions/getusers.php" method="post">
                <div class="form-group">
                    <label for="user">User:</label>
                    <input type="text" class="form-control" id="user" name="user">
                </div>

                <button type="submit" name="Form" id="Form" class="btn btn-default">Manage</button>
    </form>

While on "actions/getusers.php", I have this:在“actions/getusers.php”上,我有这个:

<?php

include('../../config.php');

session_start();

if( isset($_SESSION['password']) && $_SESSION['password']==$usdb_config['adminpassword'] ) {
    return true;
}
if( !isset($_SESSION['password']) ) {
    header("Location: ../login.php");
    die();
}
if( isset($_SESSION['password']) && $_SESSION['password']!==$usdb_config['adminpassword'] ) {
    header("Location: ../login.php");
    die();
}

require('../../other/casesensitivecfg.php');
$AdminPassword = $_SESSION['password'];

$locationtodb =  '../../database/'.$usdb_config['db_username'].$usdb_config['db_password'].$usdb_config['db_passphrase'].'/';
$users = file_get_contents($locationtodb.'users.txt');
$User = $_POST['user'];
$SearchUser = $User;
$pattern = preg_quote($SearchUser, '/');
$pattern = "/^.*$pattern.*\$/m";
preg_match_all($pattern, $users, $matches);
$wholeLine = implode("\n", $matches[0]);
$data = explode(":", $wholeLine);

// header('Content-Type: text/plain');

?>

And also this code between HTML codes in "actions/getusers.php" :以及 "actions/getusers.php" 中 HTML 代码之间的这段代码:

    <?php

            if( isset($_POST['Form']) ) {
                echo '
                <ul class="list-group">
                    <li class="list-group-item"><strong>User Owner: </strong>'.$data[2].'</li>
                    <li class="list-group-item"><strong>User: </strong>'.$data[0].'</li>
                    <li class="list-group-item"><strong>User Status: </strong>'.$data[1].'</li>
                </ul>
                ';
            }

            if( !preg_match_all($pattern, $users, $matches) ) {
                echo '<div class="alert alert-danger" role="alert">The user you entered does not exists!</div>';
            }

            if( $_POST['user']=="this_line_must_not_be_edited_or_removed" ) {
                echo '<div class="alert alert-danger" role="alert">The user you entered does not exists!</div>';
            }

    ?>

At last, after submitting the form on "GetUsers.php", I get blank page on "actions/getusers.php".最后,在“GetUsers.php”上提交表单后,我在“actions/getusers.php”上得到空白页。

In your actions/getusers.php script the first if terminates the script if you are using the admin password在您的actions/getusers.php脚本中,如果您使用管理员密码,第一个if终止脚本

<?php

include('../../config.php');

session_start();

if( isset($_SESSION['password']) && $_SESSION['password']==$usdb_config['adminpassword'] ) {
    return true;    // This kills the script before any output is generated
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM