check2.php 545 B

1234567891011121314151617181920212223
  1. <?php
  2. session_start();
  3. include("connect.php");
  4. $id = $_POST['id'];
  5. //搜尋資料庫資料
  6. $sql = "SELECT * FROM accounts where account = '$id'";
  7. $result = mysql_query($sql);
  8. $row = @mysql_fetch_row($result);
  9. //判斷帳號與密碼是否為空白
  10. //以及MySQL資料庫裡是否有這個會員
  11. if($id != null && $row[1] == $id){
  12. //將帳號寫入session,方便驗證使用者身份
  13. $_SESSION['id'] = $row[0];
  14. $_SESSION['name'] = $row[1];
  15. header('Location: 000.php');
  16. exit;
  17. }
  18. else{
  19. header('Location: check.php');
  20. exit;
  21. }
  22. ?>