Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- header('Content-type: application/json');
- header("Access-Control-Allow-Origin: *");
- ob_end_flush();
- $id='localhost';
- $usuario='root';
- $password='asd123ftw';
- $db="l2saviors_nice_team";
- $postdata1='';
- $postdata = file_get_contents("php://input");
- $request = json_decode($postdata);
- $user = $request->user;
- $pass = $request->pass;
- $email = $request->email;
- $con=mysqli_connect($id,$usuario,$password)or die("Problemas al conectar");
- mysqli_select_db($con, $db)or die("Problemas al seleccionar la bd");
- $result = mysqli_query($con, "SELECT login FROM accounts WHERE login='$user'");
- while($row = mysqli_fetch_assoc($result)){
- $test[] = $row;
- }
- $test1=mysqli_num_rows($result);
- if($test1==0){
- mysqli_query($con, "INSERT INTO accounts (login,Password,Email) VALUES ('$user','$pass','$email')");
- $postdata1= Array(
- 'status' => 'Account has been created successfully! Have fun.'
- );
- }
- else {
- $postdata1= Array(
- 'status' => 'Error: Account already exists.'
- );
- }
- echo json_encode($postdata1);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement