会话中未定义的变量突然没有进行任何更改

时间:2012-12-14 16:48:54

标签: php mysql

enter image description here

<?

session_start();

$client_name=$_SESSION['client_name'];

if ($client_name !== 'admin')
{
include "client_header.php";
$client_id=$_SESSION['client_id'];
$first_name=$_SESSION['first_name'];
$last_name=$_SESSION['last_name'];
$remoteaddr=$_SESSION['remoteaddr'];
$date_in=$_SESSION['date_in'];
$time_in=$_SESSION['time_in'];
$cisloggedin=$_SESSION['cisloggedin'];

$url_access=$_SERVER['REQUEST_URI'] ;

$isql = "INSERT INTO patient (first_name,last_name, email, country , address , phone , gender , height , weight , bloodpressure , bloodtype)
VALUES ('$first_name','$last_name','$email','$country','$address','$phone','$gender','$height','$weight','$bloodpressure','$bloodtype')";
$result = mysql_query($isql);
?>
<h2><br>Welcome <b>
  <?=$client_name?>

  Here are your bills:
  </b></h2>

<?

$result = mysql_query("SELECT * FROM invoices WHERE clientid = '$client_id' ORDER BY id",$db);

echo "<p><table border=1 cellspacing=0 cellpadding=2 bordercolor=#000000 width=90%>";
echo "<tr align=top>
<td class=topHeadrow5><b>Inv. #</b></td>
<td class=topHeadrow5><b>Receipt Date</b></td>
<td class=topHeadrow5><b>Due Date</b></td>
<td class=topHeadrow5><b>Total</b></td>
<td class=topHeadrow5><b>Status</b></td>
<td class=topHeadrow5>&nbsp;</td></tr>";

while ($row = mysql_fetch_array($result))
{
    $id = $row["id"];
    $date = $row["date"];
    $bill_date = $row["bill_date"];
    $due_date = $row["due_date"];
    $paid_date = $row["paid_date"];
    $dateshow = fixDate($date);
    $dateshow1 = fixDate($bill_date);
    $dateshow2 = fixDate($due_date);
    $dateshow3 = fixDate($paid_date);
    $total = $row["total"];
    $status = $row["status"];

if ($alternate == "1") {
    $color = "#ffffff";
    $alternate = "2";
    }
    else {
    $color = "#c0c0c0";
    $alternate = "1";
    }

echo "<tr valign=top bgcolor=$color><td>$id</td><td>$dateshow</td><td>$dateshow2</td><td align=right>$currency$total</td>";
if($status == "paid"){
echo "<td bgcolor=#33cc33>$status</td>";
}else{
echo "<td>$status</td>";
}
echo "<td>[ <a href='invoice.php?id=$id'>view</a> ] [ <a target=_blank href='invoice_print.php?id=$id'>Print</a> ]</td></tr>";
}
echo "</table>";
//-------------------------------------------------Begin Admin-------------------------------------------------
}
elseif ($client_name == 'admin')
{
include "header.php";

$url_access=$_SERVER['REQUEST_URI'] ;

?>
<h2><br>Hello <b>
  <?=$client_name?>

  Patients List:
  </b></h2>

<?

if ($menusort1 = $menusort1) {
$result = mysql_query("SELECT invoices.*, clients.*
FROM invoices,clients
WHERE invoices.clientid = clients.clientid && invoices.date >'$ytd'
ORDER BY $menusort1 ASC",$db);

}
if ($menusort = $menusort) {
$result = mysql_query("SELECT invoices.*, clients.*
FROM invoices,clients
WHERE invoices.clientid = clients.clientid && invoices.date >'$ytd'
ORDER BY $menusort DESC",$db);

}
if (!$menusort and !$menusort1) {
$result = mysql_query("SELECT invoices.*, patient.*
FROM invoices,patient
WHERE invoices.clientid = clients.clientid && invoices.date >'$ytd'
ORDER BY id",$db);
}
echo "<p><table border=1 cellspacing=0 cellpadding=2 bordercolor=#000000 width=95%>";
echo "<tr align=top>
<td class=topHeadrow5><b>ID number: <a href='menu.php?menusort=id'><img class=arrows src=images/dn_arrow.gif></a><a href='menu.php?menusort1=id'><img class=arrows src=images/up_arrow.gif></a></b></td>
<td class=topHeadrow5><b>Name <a href='menu.php?menusort=name'><img class=arrows src=images/dn_arrow.gif></a><a href='menu.php?menusort1=name'><img class=arrows src=images/up_arrow.gif></a></b></td>
<td class=topHeadrow5><b>Out Patient<a href='menu.php?menusort=date'><img class=arrows src=images/dn_arrow.gif></a><a href='menu.php?menusort1=date'><img class=arrows src=images/up_arrow.gif></a></b></td>
<td class=topHeadrow5><b>Due Date <a href='menu.php?menusort=due_date'><img class=arrows src=images/dn_arrow.gif></a><a href='menu.php?menusort1=due_date'><img class=arrows src=images/up_arrow.gif></a></b></td>
<td class=topHeadrow5>&nbsp;</td>
<td class=topHeadrow5>&nbsp;</td>
<td class=topHeadrow5>&nbsp;</td>
<td class=topHeadrow5>&nbsp;</td></tr>";

while ($row = mysql_fetch_array($result))
{
    $id = $row["id"];
    $clientid = $row["clientid"];
    $name = $row["first_name"];
    $date = $row["date"];
    $bill_date = $row["bill_date"];
    $due_date = $row["due_date"];
    $paid_date = $row["paid_date"];
    $dateshow = fixDate($date);
    $dateshow1 = fixDate($bill_date);
    $dateshow2 = fixDate($due_date);
    $dateshow3 = fixDate($paid_date);




if ($alternate == "1") {
    $color = "#ffffff";
    $alternate = "2";
    }
    else {
    $color = "#e5e5e5";
    $alternate = "1";
    }

echo "<tr valign=top bgcolor=$color>
<td width=10>$id</td><td>$name</td>
<td>$dateshow</td><td>$dateshow2</td>
<td align=right>$currency$total</td>";
if ($status == 'pending') {
echo "<td  bgcolor=$color>$status</td>";

} else {
echo "<td class=rowviewinv >$status</td>";
}
if ($status == 'pending') {
echo "<td>[ <a href='admin_invoice.php?id=$id'>view / change status</a> ]</td>";
}
else {
echo "<td class=rowviewinv>[ <a class=inv_links href='admin_invoice.php?id=$id'>view</a> ]</td>";
}
if ($status == 'pending') {
echo "<td>[ <a href='notifyclient.php?id=$id&clientid=$clientid'>notify client</a> ]</td>";
} else {
echo "<td class=rowviewinv>[ Paid $dateshow3 ]</td>";
}

echo "<td>[ <a href='edit_invoice.php?id=$id'>edit</a> ]</td><td>[ <a href='delete_invoice.php?id=$id' onClick=\"return confirm('Are you sure?')\">delete</a> ]</td></tr>";
}
$result = mysql_query("SELECT sum(total) AS sum FROM invoices WHERE date >'.$ytd.'");
$sum = mysql_result($result,0,"sum");

if ($sum == 1){
echo "";
}else{
echo "";
}
echo "</table>";

?>
<p align="center"><font class="medBold">You can review previous dates by selecting from the calendar icons.
</font></p>
<form method="post" name=form1 action="invoice_history.php">
<input type="text" name="invdate" id="invdate">
<img src="img.gif" id="f_trigger_c"
     style="cursor: pointer; border: 1px solid red;"
     title="Date selector"
     onmouseover="this.style.background='red';"
     onmouseout="this.style.background=''" />
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "invdate",
        ifFormat       :    "%Y-%m-%d",
        button         :    "f_trigger_c",
        align          :    "Tl",
        singleClick    :    true
    });
</script>
<input type="Submit" name="submit" value="Submit Invoice Date"></form>
<?
}

?>
之前它运作良好。我没有做任何事,因为我不是那个制作代码的人。我唯一做的是将文件复制到一个新文件夹,但这两个文件都不起作用。在数据库中,我确实修改了一些但不在该程序正在使用的数据库中的数据库。

2 个答案:

答案 0 :(得分:3)

include "client_header.php";

您缺少此文件,因此可能会抛弃其余代码。您可能已将这些文件移动到不同的目录,更改include以允许更改目录。

代码中还有其他include,所以也要更新它们。

//编辑

检查原始来源,正如您所说这是其他人的代码,可能会有副本存在。 include命令表示client_header.php文件可用,可以在同一文件夹中,也可以作为PATH的一部分。有关详细信息,请参阅Php include文档和notes on include_path

唯一的另一种可能性是这些错误之前存在但由于php设置而不可见。

答案 1 :(得分:0)

您移动了脚本,因此您需要更正包含路径:

include "client_header.php";

这是期望当前目录中的include,因此如果您将其移动到子目录,则可以在其前面添加../或为其指定绝对路径。