Bez popisu

loginUserAdd.php 923B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?PHP
  2. // ---------------
  3. // Connection to server and database
  4. // ---------------
  5. $host = "localhost";
  6. $basedatos = "techos";
  7. $user = "pablo.puig1";
  8. $passw = "9NA3kSExI2fGE6eV";
  9. try{
  10. $connection = mysqli_connect($host, $user, $passw, $basedatos) or $error = 1;
  11. }
  12. catch(Exception $ex){
  13. print("Error connecting to database: ". $ex->getMessage()) and die();
  14. }
  15. // //---------------
  16. // // Query and sending results
  17. // //---------------
  18. header('Content-Type: application/json');
  19. $encodedData=file_get_contents('php://input');
  20. $decodedData=json_decode($encodedData, true);
  21. $addName=$decodedData["name"];
  22. $addEmail=$decodedData["email"];
  23. $addPhone=$decodedData["phone"];
  24. $queryAddUser = "INSERT INTO users (name, email, phone_num) VALUES ('$addName', '$addEmail', '$addPhone')";
  25. mysqli_query($connection, $queryAddUser);
  26. // $stmtAdd = mysqli_prepare($connection, $queryAddUser);
  27. // mysqli_stmt_execute($stmtAdd);
  28. ?>