Advertisement
nedfire

httppost

Apr 21st, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. <?php
  2. header("Access-Control-Allow-Origin: *");
  3. header("Content-Type: application/json; charset=UTF-8");
  4. //include('sqliconn.php');
  5. $conn = new mysqli('localhost', 'root', '', 'pwd');
  6. if ($conn -> connect_error){
  7. die("Connection failed : " . $connect_error);
  8. }else
  9. {
  10. //echo "connection Successfuly";
  11.  
  12. }
  13.  
  14. //Creating Array for JSON response
  15. $response = array();
  16.  
  17. $passwd=$_POST['passwd'];
  18. echo $passwd;
  19. $result=mysqli_query($conn, "SELECT * FROM user WHERE
  20. password= '$passwd' ");
  21. //$id =$_POST['id'];
  22. if (isset($_POST["passwd"])) {
  23. // $passwd = $_POST['passwd'];
  24.  
  25. if (!empty($result)) {
  26.  
  27.  
  28.  
  29. if(mysqli_num_rows($result)>0) {
  30. session_start();
  31. $_SESSION["passwd"] = $passwd;
  32. session_write_close();
  33. $result = mysqli_fetch_array($result);
  34.  
  35. $password = array();
  36. // $password["id"] = $result["id"];
  37. // $password["username"] = $result["username"];
  38. //$password["password"] = $result["password"];
  39.  
  40. $response["success"] = 1;
  41.  
  42. $response["password"] = array();
  43.  
  44. // Push all the items
  45. array_push($response["password"], $passwd);
  46.  
  47. // Show JSON response
  48. echo json_encode($response);
  49. } else {
  50. // If no data is found
  51. $response["success"] = 0;
  52. $response["message"] = "No data on this password found in count";
  53.  
  54. // Show JSON response
  55. echo json_encode($response);
  56. }
  57. }
  58. else {
  59. // If no data is found
  60. $response["success"] = 0;
  61. $response["message"] = "No data on password found ,reult empty ";
  62.  
  63. // Show JSON response
  64. echo json_encode($response);
  65. }
  66. }else {
  67. // If required parameter is missing
  68. $response["success"] = 0;
  69. $response["message"] = "Parameter(s) are missing. Please check the request";
  70.  
  71. // echoing JSON response
  72. echo json_encode($response);
  73. }
  74.  
  75.  
  76.  
  77. mysqli_close($conn);
  78. //create connection to php=$
  79. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement