Advertisement
Guest User

Untitled

a guest
Mar 9th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2. header("Content-Type: application/json; charset=UTF-8");
  3.  
  4. $host = "localhost:3306";
  5. $username = "root";
  6. $password = "123";
  7. $dbname = "maordb";
  8.  
  9. $obj = filter_input(INPUT_POST,'params');
  10.  
  11. $array = json_decode($obj); // decode JSON to associative array
  12. $id = $array->id;
  13. $name = $array->name;
  14. $minimum = $array->minimum;
  15. $address = $array->address;
  16. $phonenumber = $array->phonenumber;
  17. $menus = $array->menus;
  18.  
  19. $conn = mysqli_connect($host, $username, $password ,$dbname) or die("error connect to SQL: ".mysqli_connect_error());
  20.  
  21. $sql = "INSERT INTO businesses ( businessId, name, minimum,address,phonenumber,menus) VALUES ('234234', 'מאור', '40', 'מאור', '65555555', 'toast')";
  22. if (mysqli_query($conn, $sql)) {
  23. echo "New record created successfully";
  24. } else {
  25. echo "Error: " . $sql . "<br>" . mysqli_error($conn);
  26. }
  27.  
  28. mysqli_close($conn);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement