0

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

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

这是连接 sql server 的 myfunctions.php。

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();
    }
}

这是我的 index.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>";
    }
}
}

index2.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 无法处理查询?我只是一名实习生,任何帮助将不胜感激。

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

注意:未定义索引:第 6 行 /Applications/MAMP/htdocs/ticketing/index.php 中的 User-Identity-Forward-msisdn

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

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

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

4

2 回答 2

0

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

$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

会自动解决。

于 2012-05-02T05:39:08.980 回答
0

on which page it redirects do you know?

Note: SELECT UserID FROM tblAdminUser WHERE UserID='$_username' (i know its not relevant but is USERID col belongs to username?)

于 2012-05-02T06:27:16.113 回答