PHP login mysql query 重新加载登录页面 (MAMP)


php login mysql query reloads login page (MAMP)

我已经阅读了大多数解决方案,其中登录时不断重新加载登录页面,但它仍然对我不起作用。我尝试在不同的浏览器中登录(可悲的是这里只有野生动物园和火狐浏览器(。即使我没有输入用户名或密码,也没有错误,尽管代码中有一个错误Str可以打印出错误。无论如何,它都会不断重新加载。

我是php编程的初学者,我正在尝试访问一个旧的php网站。

这是myfunctions.php sql服务器中的连接位置。

class mysql_db
{
    function openCityPassSQL()
{
        $dbhostname="localhost:8889";
        $dbusername="root";
        $dbpassword="root";         
                    $dbname="ticketing";

        MYSQL_CONNECT($dbhostname,$dbusername,$dbpassword) OR DIE("Unable to connect to database...");
        @mysql_select_db("$dbname") or die("Unable to select database..."); }
    function executeQuery($query)
    {
        return MYSQL_QUERY($query);
    }
    function executeUpdate($query)
    {
        return MYSQL_QUERY($query);
    }
    function numRows($result)
    {
        return MYSQL_NUM_ROWS($result);
    }
    function fetchRow($result)
    {
        return mysql_fetch_array($result);
    }
    function closeSQL()
    {
        MYSQL_CLOSE();
    }
}

这是我的索引.php

<?
ini_set('display_errors','1');
$found_msisdn = false;
$temp = $HTTP_COOKIE_VARS["User-Identity-Forward-msisdn"];
if (($temp != null) && ($temp != "")) {
$len = strlen($temp);
$msisdn = "+";
for ($i=0;$i<$len;$i++) {
    if (($i % 2) == 1)
        $msisdn = $msisdn . $temp[$i];
}
$found_msisdn = true;
}     
if (!$found_msisdn) {
//get SMART's MSISDN
$network    = $HTTP_SERVER_VARS["HTTP_X_NETWORK_INFO"];
//GPRS,639218025160,515031808225161,10.155.9.87,unsecured
$info   = explode(",", $network);
$msisdn = $info[1];
if (($msisdn != null) && ($msisdn != "")) {
    $msisdn = "+" . $msisdn;
    $found_msisdn = true;
}
}
if ($found_msisdn) {
$msisdn = urlencode($msisdn);
}
if (preg_match("/vnd.wap.wml/",$_SERVER['HTTP_ACCEPT'])){ 
header("Location: http://wap.surfshop.net.ph/citypass/index.wml?msisdn=$msisdn"); 
exit; 
} 

require ("myfunctions.php");
session_start();
$_showform=true;
$errorStr="";
$_username="";
$_password="";
$conn=new mysql_db();
$conn->openCityPassSQL();
if (isSet($a_exit) && $a_exit=="1") 
{
session_unregister("verified_user");
$_showform=false;
header("Location: index.php");
}
if (isSet($submitform))
{
$_username=$username;
$_password=$password;
//if (!nameIsValid($_username)) $errorStr=$errorStr.($errorStr!=""?"<br>":"")."Invalid User ID.";
//if (empty($_password) || !passwordIsValid($_password)) $errorStr=$errorStr.($errorStr!=""?"<br>":"")."Invalid Password.";
if (empty($_username)) {
    $errorStr = "Invalid username<br>";
}
if (empty($_password)) {
    $errorStr .= "Invalid password<br>";
}
if (empty($errorStr))
{
    $tid = 0;
    $query="SELECT Password, PASSWORD('$password') FROM tblUser WHERE UserID='$_username'";
    //echo "query:$query<br>";
    $result=$conn->executeQuery($query);
    $numRows=$conn->numRows($result);
    if ($result && $numRows>0) {
        $RS=mysql_fetch_array($result);
        $pass1=$RS[0];
        $pass2=$RS[1];
        if ($pass1 == $pass2) {
            $query = "SELECT EstabID FROM tblEstabUser WHERE UserID='$_username'";
            $result=$conn->executeQuery($query);
            $RS=mysql_fetch_array($result);
            $tid = $RS[0];
            $admin = false;
            $query = "SELECT UserID FROM tblAdminUser WHERE UserID='$_username'";
            //echo "query:$query<br>";
            $result=$conn->executeQuery($query);
            $numRows=$conn->numRows($result);
            if ($numRows > 0) {
                $admin = true;
                $tid = $numRows[1];             //initialize to a value for links to work
            }
            $verified_user = array($_username, $tid, ($admin?"1":"0"));
            session_register("verified_user");
            $errorStr = "Welcome $_username!<br>";  
            $_showform = false;
            header("Location: index2.php");
        }
        else {
            $errorStr = "Invalid username/password (PA)<br>";
        }
            }
    else {
        $errorStr = "Invalid username/password (NR)<br>";
    }
}
}

索引2.php

session_start();
$_showform=true;
if (!session_is_registered("verified_user"))
{
    $_showform=false;
    header("Location: index.php");
}
else
{    
list($username,$estabid,$admin)=$verified_user;
if (empty($username))
{
    $_showform=false;
    header("Location: index.php");
}
}
if ($_showform)
{
?>
<html>
<head>
<title><?=$applicationName?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
  <td>
<?include("header.php");?>
  </td>
</tr>
<?
    //if ($errorStr!="")
    if ($username!="")
    {
?>
            <tr>
            </tr>
            <tr>
              <td><font face="Verdana" size="2">&nbsp;</font></td>
            </tr>
<?
    }
?>

<tr>
  <td>
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td valign="top">
<?include("menu_in.php");?>
        </td>
        <td valign="top">
           <table width="100%" border="0" cellpadding="0" cellspacing="0">
             <tr>
               <td>
               </td>
             </tr>
           </table>
        </td>

          </tr>
        </table>
      </td>
    </tr>
  </table>
</body>
</html>
<?
}
?>

我真的不知道错误是什么,但我的猜测是脚本只是旧,我的 MAMP 无法处理查询?我只是一名实习生,任何帮助将不胜感激。

这些是我遇到的以下错误:

注意:未定义的索引:用户身份转发 msisdn 在 /Applications/MAMP/htdocs/ticketing/index.php 在第 6 行

注意:未定义的索引:HTTP_X_NETWORK_INFO /Applications/MAMP/htdocs/ticketing/index.php 在第 21 行

注意:未定义的偏移量:1 英寸 /Applications/MAMP/htdocs/ticketing/index.php 在第 26 行

警告:session_start(( [function.session-start]:无法发送会话 缓存限制器 - 标头已发送(输出开始于 /Applications/MAMP/htdocs/ticketing/index.php:6( in /Applications/MAMP/htdocs/ticketing/index.php 在第 45 行

您提供的错误信息清楚地表明

$HTTP_COOKIE_VARS["User-Identity-Forward-msisdn"];
$HTTP_SERVER_VARS["HTTP_X_NETWORK_INFO"];

完全是空的。

请使用

print_r($HTTP_COOKIE_VARS);
print_r($HTTP_SERVER_VARS);

以检查值是否存在。如果这些数组中有值,那么你的第三个问题

Notice: Undefined offset: 1 in /Applications/MAMP/htdocs/ticketing/index.php on line 26

将自动解决。

你知道

它在哪个页面上重定向

注意:从 tblAdminUser 中选择用户 ID,其中 UserID='$_username' (我知道它不相关,但 USERID col 属于用户名吗?