2012-11-02 83 views
-2

下面的代碼打破了我的頁面...沒有顯示牆紙或表格。唯一顯示的是徽標和登錄表單。該表格假設登錄我然後顯示我的帳戶名稱和一些數字。如何修復下面的代碼?Php代碼打破背景和表格

<?php 

    include 'wasudf.php'; 

    // 
    // get session id 
    // 
    $SessionID = $_GET['SessionID']; 

    if (!$SessionID) 
     $SessionID = $_POST['SessionID']; 

    if (!$SessionID) 
     $SessionID = $_COOKIE['SessionID']; 

    if (!$Function) 
     $Function = $_GET['FunkShun']; 

    if (!$Function) 
     $Function = $_POST['FunkShun']; 

    if (!$Function) 
     $Function="Home"; 

    if (!$SessionID) 
     { 

echo'  <form action="index.php" method="post" id="LoginForm" style="color:#FFF">'; 
echo'  <input type="hidden" name="SessionID" value="new"></input>'; 
echo'  Username:'; 
echo'  <label>'; 
echo'  <input type="text" name="AccountNo" value="" class="input" size="28"></input>'; 
echo'  </label>'; 
echo'  <BR /><BR />'; 
echo'  &nbsp;&nbsp;Password:'; 
echo' <label>'; 
echo' <input type="password" name="Password" value="" class="input" size="30"></input>'; 
echo' </label>'; 
echo'  <BR /><BR />'; 
echo' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="image" src="images/input-img.gif" value="Log On" class="input-img"></input>'; 
echo' <BR /><br />'; 
echo' <a href="#" class="link" style="font-size:12px;">Register now!</a> <a href="#" style="font-size:12px;">Forgotten your password?</a> '; 
echo' </form>'; 

return; 
     } 

    // 
    // this is a new session - add to web session table 
    // 
    if ($SessionID == "new") 
     { 
     $AccountNo = check_input(strtoupper(trim($_POST['AccountNo']))); 
     $Password = check_input(strtoupper(trim($_POST['Password']))); 

     if (!$AccountNo) 
     ExitLogOn("Invalid Account/Password"); 

     $rs=mysql_query("select * from accounts where code='$AccountNo' and password='$Password'",$db); 
     $row=mysql_fetch_array($rs); 

     if (!$row) 
     ExitLogOn("Invalid Account/Password!"); 

     mysql_query("update system set nextsession = nextsession + 1",$db); 

     $rs=mysql_query("select * from system",$db); 
     $row=mysql_fetch_array($rs); 

     $SessionID = $row['nextsession']; 

     // 
     // ensure this session does not exist already 
     // also remove any sessions belonging to this account 
     // - ie account can only be logged on one workstation at any time 
     // 
     mysql_query("delete from websession where sessionid='$SessionID' or account='$AccountNo'",$db); 

     $Expiry=strtotime("+1 hour"); 

     $xCommand = "insert into websession set "; 
     $xCommand = $xCommand . "sessionid='$SessionID',"; 
     $xCommand = $xCommand . "ipaddress='" . $_SERVER['REMOTE_ADDR'] . "',"; 
     $xCommand = $xCommand . "account='$AccountNo',"; 
     $xCommand = $xCommand . "password='$Password',"; 
     $xCommand = $xCommand . "date='" . date('YmdHis',$Expiry) . "'"; 

     mysql_query($xCommand,$db); 
     } 

    $rs=mysql_query("select * from websession where sessionid='$SessionID'",$db); 
    $row=mysql_fetch_array($rs); 

    if (!$row) 
     { 
     mysql_query("delete from websession where sessionid='$SessionID'",$db); 
     mysql_query("delete from elist where code='$SessionID'",$db); 
     ExitLogOn("Session Expired"); 
     } 

    if ($row['date'] < date('YmdHis')) 
     { 
     mysql_query("delete from websession where sessionid='$SessionID'",$db); 
     mysql_query("delete from elist where code='$SessionID'",$db); 
     ExitLogOn("Session Expired!!"); 
     } 

    $Expiry=strtotime("+1 hour"); 

    $xCommand = "update websession set "; 
    $xCommand = $xCommand . "date='" . date('YmdHis',$Expiry) . "'"; 
    $xCommand = $xCommand . "where sessionid='$SessionID'"; 

    mysql_query($xCommand,$db); 

    $AccountNo = $row['account']; 
    $Password = $row['password']; 
    $MiscData = $row['data']; 

    $rs=mysql_query("select * from accounts where code='$AccountNo' and password='$Password'",$db); 
    $row=mysql_fetch_array($rs); 

    if (!$row) 
     ExitLogOn("Invalid Account/Password!!"); 

    $Name = trim($row['name']); 
    $Balance = $row['balance']; 

     if ($Function == "Home") 
     { 
     echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post">'; 
     echo '<input type="hidden" name="SessionID" value="' . $SessionID . '"></input>'; 
     echo '<table width=800 align=center>'; 

     echo ' <tr>'; 
     echo '  <td align=center colspan="4" style="color:#F93;">'; 
     echo   $Name; 
     echo '  </td>'; 
     echo ' </tr>'; 

     echo ' <tr>'; 
     echo '  <td align=center colspan="4" style="color:#F93;">'; 
     echo '   Current Balance $ ' . snumber($Balance,10); 
     echo '  </td>'; 
     echo ' </tr>'; 

     echo ' <tr>'; 
     echo '  <td align=center colspan="4">'; 
     echo '   &nbsp'; 
     echo '  </td>'; 
     echo ' </tr>'; 

     echo '</table>'; 
     echo '</form>'; 
     } 

?> 
+0

如何在不更改上述編碼的情況下更正此問題? –

+0

您可能有一些HTML錯誤,例如非結束標記。您可以使用驗證器http://validator.w3.org/來檢查您生成的HTML代碼。我們無法通過代碼轉儲幫助您解決問題。 – Tchoupi

+0

1)如果您沒有提供「It is not working」以外的任何信息,您如何指望我們知道什麼是錯誤的。 2)不要使用'mysql'函數 – thatidiotguy

回答

0

您使用的是同一個頁面上都GETPOST

$SessionID = $_GET['SessionID']; 

if (!$SessionID) 
    $SessionID = $_POST['SessionID']; 

if (!$SessionID) 
    $SessionID = $_COOKIE['SessionID']; 

if (!$Function) 
    $Function = $_GET['FunkShun']; 

if (!$Function) 
    $Function = $_POST['FunkShun']; 

什麼是所有重新分配$Function

+0

即時通訊新手抱歉大家:(很容易我的代碼被創建,我設計了一個圍繞代碼的網站。 –

+0

感謝大家的回覆,我們非常感謝您的幫助。 –