Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 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");
  24.         $userdata = $result->fetch_object();
  25.         if($username==$userdata->username){
  26.             $result1=array('status'=>'2');
  27.         }
  28.         else{
  29.                 $query = "INSERT INTO utilizador (nome, morada, user, pass, telefone)
  30.                VALUES ('$nome','$morada','$username','$password','$telefone')";
  31.  
  32.                         $result = mysqli_query($dbconn, $query);
  33.  
  34.                        
  35.  
  36.                 if($result){
  37.                    
  38.                     $result1=array('status'=>'1');
  39.                 }
  40.                 else{
  41.                     $result1=array('status'=>'0');
  42.                 }
  43.         }
  44.  
  45.        
  46.  
  47.         echo json_encode($result1);
  48.         session_write_close();
  49.    
  50.  
  51.  
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement