Php 分析错误:语法错误,LDAP登录表单上出现意外的$end
我想在我的网站上为我的一些管理工具创建一个LDAP登录页,但在使用了一些模板后遇到了问题。我最终选择了一个我认为可以满足我需要的模板/教程,制作了适当的文件并调整了变量,只是为了在发布后得到一个Php 分析错误:语法错误,LDAP登录表单上出现意外的$end,php,Php,我想在我的网站上为我的一些管理工具创建一个LDAP登录页,但在使用了一些模板后遇到了问题。我最终选择了一个我认为可以满足我需要的模板/教程,制作了适当的文件并调整了变量,只是为了在发布后得到一个Parse error:syntax error,意外的$end error。我只是在寻找一些指导,如何使这个项目成功 <?php // http://sudobash.net/?p=736 session_start(); session_destroy(); if(!isset($_POST[
Parse error:syntax error,意外的$end error
。我只是在寻找一些指导,如何使这个项目成功
<?php
// http://sudobash.net/?p=736
session_start();
session_destroy();
if(!isset($_POST['user'])){?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>LOGIN TITLE</title>
</head>
<body>
<table align="center" height="200px" id="content">
<tr>
<td valign="middle">
<h2>TITLE Login</h2>
<form action="login.php" method="POST">
<tt>RAC Username:</tt>
<input type="text" name="user" size="30" /><br />
<tt>RAC Password:</tt>
<input type="password" name="password" size="30" />
<input type="submit" value="Login" name="submit" />
</form>
</td>
</tr>
</table>
</body>
</html>
<?}?>
<?if(isset($_POST['user'])){?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -->
<head>
<title>LOGIN RESULTS TITLE</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
include 'conf.php';
// Don't display the warnings - we are already setup to annoy the user
ini_set( "display_errors", 0);
// No funny stuff!
$user = htmlspecialchars($_POST['user']);
$user = explode(" ", $user);
$user = $user[0];
$user = preg_replace("/[^a-zA-Z0-9_]/", "", $user);
$filter = "admin=" . $user;
// Connect to the LDAP server.
$ldapconn = ldap_connect($server, $port) or
die("Could not connect to " . $server . ":" . $port . ".");
// Bind with rootreader to the LDAP server to search and retrieve DN.
$ldapbind = ldap_bind($ldapconn) or die("Could not bind - contact admin@adamskalicky.com");
$result = ldap_search($ldapconn,$basedn,$filter) or die ("Search error.");
$entries = ldap_get_entries($ldapconn, $result);
$binddn = $entries[0]["dn"];
// Bind again using the DN retrieved. If this bind is successful,
// then the user has managed to authenticate.
$ldapbind = ldap_bind($ldapconn, $binddn, $_POST['password']);
if ($ldapbind) {
echo "<center><h2>Successful authentication for <span style='color: #000;'>" . $user . "</span></center>";
?> <table align="center" height="200px" id="content">
<tr>
<td valign="middle">
<form action="restricted.php" method="post">
<input type="hidden" name='user' value="<?=$user;?>" >
<input type="submit" value="Great, Let's go!" >
</form>
</td>
</tr>
</table>
<?
} else {
echo "<center><h2>Failed authentication for <span style='color: #000;'>" . $user . "</span><br /><br />
<a href='login.php'>Try again</a></center>";
}
ldap_close($ldapconn);
?>
</body>
</html>
<?}?>
登录名
标题登录
RAC用户名:
RAC密码:
登录结果标题
当您不使用PHP短标记时,问题已经解决。
你能在你自己的服务器上试试吗
无论如何,使用shorttags不是一件好事。您发布的代码中没有明显的PHP错误。包含的文件中可能有一个。从末尾删除
,并在ldap\u关闭($ldapconn)后添加它代码>语句,如下所示:ldap\u close($ldapconn);}>代码>@AmalMurali,我更改了'ldap\u close($ldapconn);?>ldap_close($ldapconn);}?>'但是仍然会得到相同的错误。@Sébastien唯一包含的文件是我的conf.php文件,它只包含我的服务器设置。以防万一,这里是:我也没有看到任何会导致错误的东西。您确定页面中绝对没有其他代码吗?你能试着只写你在一个独立页面上发布的代码,然后上传到你的服务器上,看看它是否有效吗?