2013-06-13 65 views
0

我正在一個培訓和安置網站,我有一個小問題,但我卡住了..希望我會幫助.. 登錄頁面的代碼如下給出... This是tpr.php我不能提交表格

<?php require_once("includes/tsession.php");?> 
<?php require_once("includes/connection.php");?> 
<?php require_once("includes/functions.php");?> 
<?php 

    if (isset($_POST['submit'])) 
    { 
     $branch = trim(mysql_prep($_POST['branch'])); 
     $tprid = trim(mysql_prep($_POST['tprid'])); 
     $password = trim(mysql_prep($_POST['password'])); 

     $hashed_password = sha1($password); 

     $query = "SELECT t.userID FROM tpr t,branch b WHERE b.branch_ID=t.branch_id AND b.branch_name='{$branch}'  
     AND t.password = '{$hashed_password}' AND t.userID='{$tprid}' limit 1" or die(mysql_error());  
      $result_set = mysql_query($query); 
      confirm_query($result_set); 


      if (mysql_num_rows($result_set) == 1) { 
       // username/password authenticated 
       // and only 1 match 

       echo "<script type='text/javascript'>alert('Username /password/branch combination correct.');</script>"; 
       $found_user = mysql_fetch_array($result_set); 



       $_SESSION['sessionid2']=$found_user['Userid']; 
       redirect_to("tpr.php"); 
      } else { 
       // username/password combo was not found in the database 

       echo "<script type='text/javascript'>alert('Username/password/branch combination incorrect.');</script>";  
       $message = "Username/password/branch combination  incorrect.<br />  
      } 
    } 
    else{ 
    if(isset($_GET['logout']) && ($_GET['logout']==1)) 
    { 
     $message= "You are now logged out"; 
    } 
    echo "<script type='text/javascript'>alert('out of submit');</script>"; 

    $tpoid=""; 
    $password=""; 
    } 
?> 
<?php include("includes/header.php"); ?> 
<div id="main"> 
    <table id="structure"> 
    <tr> 
    <td id="navigation"> 
    <a href="content.php">Return to Home</a> 
    </td> 
    <td id="page"> 
    <h2>Login</h2> 
    <?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?> 
    <form action="tpr_login.php" method="post"> 
    <table id="inner" cellpadding="10"> 
    <tr> 
    <td>Select Branch</td> 
    <td> 

<?php 

$con = mysql_connect("localhost","TestUserFirst","TestUserFirst"); 
$db = mysql_select_db("student",$con); 
$get=mysql_query("SELECT branch_name FROM branch ORDER BY branch_ID ASC"); 
$option = ''; 
while($row = mysql_fetch_assoc($get)) 
{ 
    $option .= '<option value =  "'.$row['branch_name'].'">'.$row['branch_name'].'</option>'; 
} 
?> 
<select name="branch" id="branch"> 
<?php echo $option; ?> 
</select> 
</td> 
</tr> 
    <tr> 
    <td>TPRId</td> 
    <td><input type=text name="tprid" id="tprid" value=""></td> 
    </tr><tr> 
    <td>Password</td> 
    <td><input type=password name="password" id="password" value=""></td> 
    </tr><tr> 
    <td></td> 
    <td><input type="submit" name="submit" value="Login"></td> 
    </tr> 
    </table> 
    </td> 
    </tr> 
    </form> 

    </table> 
</div> 
<?php require("includes/footer.php");?> 

tsession包含在session_start()和會話信息..

<?php 
session_start(); 
function tpr_logged_in() 
{ 
return isset($_SESSION['sessionid2']); 
} 

function confirm_tpr_logged_in() 
{ 
if(!tpr_logged_in()) 
{ 
    redirect_to("tpr_login.php"); 
} 
} 
?> 

連接包含數據庫初始化......問題是,每當我輸入正確的信息,它顯示「超出提交「警惕,如果一個信息是錯誤的,那就去吧es進入提交和返回密碼組合不正確......顯然......問題是什麼?

+0

變化按鈕從提交到其他 –

+1

名行是這樣的tpr.php或tpr_login.php?爲您的表單提交到tpr_login.php – Dru

+0

插入表單標籤兩個表 –

回答

1
<div id="main"> 
    <table id="structure"> 
     <tr> 
      <td id="navigation"><a href="content.php">Return to Home</a></td> 
      <td id="page"> 
       <h2>Login</h2> 


    <?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?> 
    <form action="tpr_login.php" method="post"> 
    <table id="inner" cellpadding="10"> 
    <tr> 
    <td>Select Branch</td> 
    <td> 

<?php 

$con = mysql_connect("localhost","TestUserFirst","TestUserFirst"); 
$db = mysql_select_db("student",$con); 
$get=mysql_query("SELECT branch_name FROM branch ORDER BY branch_ID ASC"); 
$option = ''; 
while($row = mysql_fetch_assoc($get)) 
{ 
    $option .= '<option value =  "'.$row['branch_name'].'">'.$row['branch_name'].'</option>'; 
} 
?> 
<select name="branch" id="branch"> 
<?php echo $option; ?> 
</select> 
</td> 
</tr> 
    <tr> 
    <td>TPRId</td> 
    <td><input type=text name="tprid" id="tprid" value=""></td> 
    </tr><tr> 
    <td>Password</td> 
    <td><input type=password name="password" id="password" value=""></td> 
    </tr><tr> 
    <td></td> 
    <td><input type="submit" name="submit" value="Login"></td> 
    </tr> 
    </table> 
    </form> 
    </td> 
     </tr> 
    </table> 
</div> 

</form>標籤</table>,而不是</tr>後後。

我不確定,但你可以試試這個。沒有檢查它不可能說實際的問題。

+0

不,我嘗試過...它不工作 –

0

有一個缺失'';'下面

$message = "Username/password/branch combination incorrect.<br />"; 
+0

然後也...它不工作 –

+0

可能包含任何文件改變POST數組? – Dru