Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 同一页面上的表单处理不会';t显示结果_Php_Html - Fatal编程技术网

Php 同一页面上的表单处理不会';t显示结果

Php 同一页面上的表单处理不会';t显示结果,php,html,Php,Html,我是网络开发新手。尝试创建一个登录页面,该页面处理用户信息并在同一页面上抛出错误,而不是重定向到error.php。页面刷新,但提交时不显示任何消息。这是代码 <?php //check if form has been submitted if(isset($_POST['submit'])) { //check if the variables are null if (empty($user) || empty($password) || empty($domain)) {

我是网络开发新手。尝试创建一个登录页面,该页面处理用户信息并在同一页面上抛出错误,而不是重定向到error.php。页面刷新,但提交时不显示任何消息。这是代码

<?php
//check if form has been submitted
if(isset($_POST['submit'])) {

//check if the variables are null
if (empty($user) || empty($password) || empty($domain)) {
    $msg = "<p>Username, Password and Domain cannot be blank</p>";
} else {
    //sanitize the data
    $user = htmlspecialchars (stripslashes (trim ($_POST['user'])));
    $password = htmlspecialchars (stripslashes (trim ($_POST['password'])));
    $domain = htmlspecialchars (stripslashes (trim ($_POST['domain'])));

    //access group variables
    $sausers = "user accounts not member of below groups which need admin access";
    $sagroup = "user group which needs admin access";
    $agroup = "user group which needs user access";
    //$accesslevel = 0;

    //assign LDAP variables based on user domain
    if ($domain == "domain"){
        $ldap_host = "childdomain.domain.com";
        $ldap_user = $user."@childdomain.domain.com";
        $ldap_dn = "DC=childdomain,DC=domain,DC=com";
    }

    //Connect to LDAP Directory
    $ldap = ldap_connect($ldap_host);
    ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION,3);
    ldap_set_option($ldap, LDAP_OPT_REFERRALS,0);
    If ($bind = @ldap_bind($ldap,$ldap_user,$password)) {

        //authentication against AD successful
        $filter = "(sAMAccountName=".$user.")";
        $attr = array("memberof");
        if ($result = ldap_search($ldap, $ldap_dn, $filter, $attr)) {
            $groups = ldap_get_entries($ldap, $result);
            ldap_unbind($ldap);

            //check if user is listed in $sausers
            If(strops($sausers, $user) != false) {
                //access granted - ideally redirect to admin page
                $msg = "<p>Welcome Super Admin</p>";
            }
            //check if user is member of admin team
            foreach($groups[0]['memberof'] as $group) {

                // check if user is a member of admin team
                if(strpos($group, $sagroup) != false) {
                    //access granted - ideally redirect to admin page
                    $msg = "<p>Welcome Super Admin</p>";
                } elseif (strpos($group, $agroup) != false) {
                   //access granted - ideally redirect to admin page
                    $msg = "<p>Welcome user</p>";
                }
            }
        } else {
            //Unable to search LDAP server
            ldap_unbind($ldap);
            $msg = "<p>We are facing issues with LDAP search at this time. Please report this issue to us by emailing emailaddress</p>";
        }
    } else {
        //AD authentication failed
        $msg = "<p>Domain Authentication Failed!!! Please try again.</p>";
    }
}
   }
?>
<!DOCTYPE html>
<html lang="en"> 
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Admin Login</title>
  <link rel="stylesheet" href="css/login.css">
</head>
<body>
 <div class="logincontainer">
<div class="login">
    <h1>RCP Ops Admin Console Login</h1>
        <form action="<?php htmlentities(urldecode($_SERVER['PHP_SELF']));?>" method="post">
        <p><b></b><input type="text" name="user" value="" placeholder="user" required autocomplete="off"></p>
        <p><b> </b><input type="password" name="password" value="" placeholder="Password" required autocomplete="off"></p>
        <p><select name="domain" placeholder="Domain">
            <option value="Select DOMAIN">DOMAIN</option>
            <option value="NANET">childdomain1</option>
            <option value="EUNET">childdomain2</option>
            <option value="APNET">childdomain3</option>
            <option value="JPNET">childdomain4</option>
        </select>
        </p>
        <p class="submit"><input type="submit" name="submit" value="Login"></p>
    </form>
</div>
</div>
<div class="error">
    <?print "<p>.$msg.</p>";?>
</div>

管理员登录
RCP Ops管理控制台登录

您忘记在此处重新打开php标记:

<div class="error">
    <?print "<p>.$msg.</p>";?>
</div>

应该是:

<div class="error">
    <?php print "<p>.$msg.</p>";?>
</div>


我假设我试图输入错误的凭据,但它仍然没有显示任何消息。与正确的凭据相同。我想知道现在是否正在处理php代码。@Ravi您是否尝试过
print\r($\u POST)
var\u dump()
?您的页面是在实际的web服务器上运行,还是仅在本地打开?页面位于实际的web服务器(2012年2月2日的web服务器IIS 8.5)上,我正在从另一台计算机访问它们。print_r()或var_dump()也不会改变结果。您能给我们提供到托管页面的链接吗?嗨,谢谢。我不认为这些话题与我正在处理的这个问题重复。