No Description

loginUserAdd.php 981B

1234567891011121314151617181920212223242526272829303132333435363738
  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. $addAccType=$decodedData["ACC"];
  22. $addName=$decodedData["name"];
  23. $addEmail=$decodedData["email"];
  24. $addPhone=$decodedData["phone"];
  25. $queryAddUser = "INSERT INTO users (acc_type, name, email, phone_num) VALUES ('$addAccType', '$addName', '$addEmail', '$addPhone')";
  26. mysqli_query($connection, $queryAddUser);
  27. // $stmtAdd = mysqli_prepare($connection, $queryAddUser);
  28. // mysqli_stmt_execute($stmtAdd);
  29. ?>