Advertisement
Guest User

Untitled

a guest
Feb 14th, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. <?php
  2. $connect = mysqli_connect("","","","");
  3. global $connect;
  4.  
  5. if (isset($_POST['login']) )
  6. {
  7. $login = $_POST['login'];
  8.  
  9. $sql = "SELECT * FROM table WHERE login='$login'";
  10. $result = mysqli_query($connect, $sql);
  11. if ($result && mysqli_num_rows($result) > 0){
  12. while ($row = mysqli_fetch_array($result)) {
  13.  
  14. $login_db = $row['login'];
  15. $real_namedb = $row['real_name'];
  16. $email_db = $row['email'];
  17. $dept_db = $row['dept'];
  18. $division_db = $row['division'];
  19.  
  20. $output= array('messages' => '1',
  21. 'login' => $login_db,
  22. 'real_name' => $real_namedb,
  23. 'email' => $email_db,
  24. 'dept' => $dept_db,
  25. 'division' => $division_db
  26. );
  27. echo json_encode($output);
  28. exit();
  29. }
  30. mysqli_free_result($result);
  31. }
  32. else {
  33. $output = array('messages' => '2', 'login' => 'wrong credentials from PHP code!');
  34. echo json_encode($output);
  35. echo mysqli_error($connect);
  36. exit();
  37. }
  38. }
  39. else
  40. {
  41. $output = array('messages' => '3', 'login' => 'No post data');
  42. echo json_encode($output);
  43. exit();
  44. }
  45. ?>
  46. <!DOCTYPE html>
  47. <html>
  48. <head><title></title>
  49. </head>
  50. <body>
  51. <form action="test.php" method="post">
  52. <table>
  53. <tr>
  54. <td><i class="fa fa-unlock-alt"></i> </td>
  55. <td>Email : </td>
  56. <td><input type ="text" name="login" size="30"></td>
  57. </tr>
  58. </table>
  59.  
  60. <p><input type ="submit" name="Submit" value="DISPLAY"> </p>
  61. </form>
  62. </body>
  63. </html>
  64.  
  65. {"messages":"1","login":"ID0111","real_name":"NAME HERE","email":"mail@mail.com","dept":"IT","division":"MDO"}
  66. {"messages":"1","login":"ID0112","real_name":"NAME HERE2","email2":"mail@mail.com","dept":"IT","division":"MDO"}
  67.  
  68. {
  69. "login":"ID0111",
  70. "real_name":"NAME HERE",
  71. "messages":
  72. [
  73. {
  74. "refno":"1234",
  75. "email":"mail@mail.com",
  76. "dept":"IT",
  77. "division":"MDO"
  78. },
  79. {
  80. "refno":"1345",
  81. "email":"mail2@mail.com",
  82. "dept":"IT",
  83. "division":"MDO"
  84. },
  85. ]
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement