Advertisement
Guest User

Untitled

a guest
May 8th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <html>
  2. <head>
  3.  
  4. </head>
  5.  
  6.  
  7.  
  8. <body>
  9.  
  10.  
  11. <script>
  12.  
  13. </script>
  14. <form action="<?php include 'file.php';?>" method="POST">
  15. <b>Busque Jรก</b>
  16. <input type="text" name="prestador" placeholder="prestador">
  17. <input type="text" name="cidade" placeholder="cidade">
  18. <input type="submit">
  19. </form>
  20.  
  21. </body>
  22.  
  23.  
  24. </html>
  25.  
  26. <?php
  27.  
  28.  
  29. $servername = "localhost";
  30. $username = "username";
  31. $password = "";
  32. $dbname = "test";
  33. $namer = $_POST['prestador'];
  34. $cities = $_POST['cidade'];
  35. // Create connection
  36. $conn = new mysqli($servername, $username, $password, $dbname);
  37. // Check connection
  38. if ($conn->connect_error) {
  39. die("Connection failed: " . $conn->connect_error);
  40. }
  41.  
  42. $sql = "SELECT name,address,city FROM tb_prestadores WHERE name = '$namer' AND city = '$cities'";
  43. $result = $conn->query($sql);
  44.  
  45. if ($result->num_rows > 0) {
  46. // output data of each row
  47. while($row = $result->fetch_assoc()) {
  48. echo "name: " . $row['name']. " Endereço - : " . $row['address']." Cidade :".$row['city']."<br>";
  49. }
  50. } else {
  51. echo "It is going to else";
  52. }
  53. $conn->close();
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement