Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <?php
  2.  
  3. // if(isset($_POST['username']) & isset($_POST['password']) & isset($_POST['nome'])){
  4.  
  5. session_start();
  6. $header = "Content-Type: application/json";
  7. header($header);
  8.  
  9. include_once('connect.php');
  10. $result1 = array();
  11. /*$nome = $_POST['nome'];
  12. $morada = $_POST['morada'];
  13. $username = $_POST['user'];
  14. $password = $_POST['pass'];
  15. $telefone = $_POST['telef'];*/
  16.  
  17. $nome = "michel123";
  18. $morada = "michel123";
  19. $username = "michel123";
  20. $password = "michel123";
  21. $telefone = "123";
  22.  
  23. $result = $dbconn->query("SELECT * FROM utilizador WHERE username=$username");
  24. $total_records = $result->num_rows;
  25. if($total_records >= 1){
  26.  
  27. $result1=array('status'=>'2');
  28. }
  29. else{
  30. $query = "INSERT INTO utilizador (nome, morada, user, pass, telefone)
  31. VALUES ('$nome','$morada','$username','$password','$telefone')";
  32.  
  33. $result = mysqli_query($dbconn, $query);
  34.  
  35.  
  36.  
  37. if($result){
  38.  
  39. $result1=array('status'=>'1');
  40. }
  41. else{
  42. $result1=array('status'=>'0');
  43. }
  44. }
  45.  
  46.  
  47.  
  48. echo json_encode($result1);
  49. session_write_close();
  50.  
  51.  
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement