Advertisement
Guest User

Untitled

a guest
Apr 13th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2. $host='localhost';
  3. $username='tan';
  4. $password='1234567';
  5. $db='feedback01';
  6.  
  7. $conn=mysqli_connect($host,$username,$password,$db);
  8.  
  9. if (!$conn)
  10. {
  11. die('Could not connect: ' . mysqli_connect_error());
  12. }
  13. $studentID=$_POST['StudentID'];
  14.  
  15. $studentID=mysqli_real_escape_string($conn,$studentID);
  16. $query="SELECT * From PassportData WHERE StudentID='$studentID'";
  17. $result=mysqli_query($conn,$query);
  18. $response = array();
  19. if(mysqli_num_rows($result)>0)
  20. {
  21. $row = mysqli_fetch_assoc($result);
  22. $event = $row["Events"];
  23. $date = $row["Date"];
  24. $code = "login_success";
  25. array_push($response, array("code"=>$code, "Events"=>$event, "Date"=>$date));
  26. echo json_encode($response);
  27. }
  28. else{
  29. $code = "login_failed";
  30. $message = "not found!";
  31. array_push($response, array("code"=>$code, "messsage"=>$message));
  32. echo json_encode($response);
  33. }
  34. mysqli_close($conn);
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement