check2.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. header("Content-type:text/html;charset=utf-8");
  3. session_start();
  4. include "connect.php";
  5. $id = $_POST['id'];
  6. //搜尋資料庫資料
  7. $sql = "SELECT * FROM accounts where account = '$id'";
  8. $result = mysql_query($sql);
  9. $row = @mysql_fetch_row($result);
  10. //判斷帳號與密碼是否為空白
  11. //以及MySQL資料庫裡是否有這個會員
  12. if ($id != null && $row[1] == $id) {
  13. //將帳號寫入session,方便驗證使用者身份
  14. $_SESSION['id'] = $row[0];
  15. $_SESSION['name'] = $row[1];
  16. $_SESSION['type'] = $row[3]; //人员身份
  17. /*$userinfo = [
  18. 'id' => $row[0],
  19. 'name' => $row[1],
  20. 'token' => $row[2],
  21. 'type' => $row[3],
  22. ];
  23. $id = $row[0]; //accid
  24. $name = $row[1];
  25. $token = $row[2];
  26. require './connectnim.php';
  27. if (empty($token)) {
  28. $token = $p->gettokenforapp($userinfo);
  29. if (empty($token)) {
  30. exit("无用户token");
  31. }
  32. $sql = "UPDATE accounts SET token = '" . $token . "' WHERE aid = " . $id;
  33. $result = mysql_query($sql);
  34. }
  35. $_SESSION['token'] = $token;
  36. //获取聊天室roomid
  37. $sql1 = "SELECT aid FROM accounts where type=1 limit 0,1";
  38. $result1 = mysql_query($sql1);
  39. $row1 = @mysql_fetch_row($result1);
  40. $createaccid = $row1[0];
  41. $result = $p->chatroomCreate($createaccid, $name . '_' . date("YmdHis"));
  42. var_dump($result);exit;
  43. $roomidresult = $p->queryUserRoomIds($createaccid);
  44. var_dump($roomidresult);exit;
  45. $roomid = 1;
  46. //获取聊天室地址
  47. $result = $p->chatroomRequestAddr($roomid, $id);*/
  48. //header('Location: 000.php');
  49. header('Location: 001.html');
  50. exit;
  51. } else {
  52. header('Location: check.php');
  53. exit;
  54. }