Advertisement
Guest User

Untitled

a guest
Aug 17th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. header('Content-type: application/json');
  4. header("Access-Control-Allow-Origin: *");
  5. ob_end_flush();
  6.  
  7.  
  8.  
  9. $id='localhost';
  10. $usuario='root';
  11. $password='asd123ftw';
  12. $db="l2saviors_nice_team";
  13. $postdata1='';
  14. $postdata = file_get_contents("php://input");
  15. $request = json_decode($postdata);
  16. $user = $request->user;
  17. $pass = $request->pass;
  18. $email = $request->email;
  19. $con=mysqli_connect($id,$usuario,$password)or die("Problemas al conectar");
  20. mysqli_select_db($con, $db)or die("Problemas al seleccionar la bd");
  21. $result = mysqli_query($con, "SELECT login FROM accounts WHERE login='$user'");
  22.  
  23.  
  24. while($row = mysqli_fetch_assoc($result)){
  25. $test[] = $row;
  26. }
  27.  
  28. $test1=mysqli_num_rows($result);
  29.  
  30. if($test1==0){
  31.  
  32. mysqli_query($con, "INSERT INTO accounts (login,Password,Email) VALUES ('$user','$pass','$email')");
  33.  
  34. $postdata1= Array(
  35. 'status' => 'Account has been created successfully! Have fun.'
  36. );
  37. }
  38. else {
  39. $postdata1= Array(
  40. 'status' => 'Error: Account already exists.'
  41. );
  42. }
  43.  
  44. echo json_encode($postdata1);
  45.  
  46.  
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement