Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `<?php
- $response = array();
- include 'db/conexionDB.php';
- include 'functions.php';
- $inputJSON = file_get_contents('php://input');
- $input = json_decode($inputJSON, TRUE);
- if(isset($input['email']) && isset($input['passw']) && isset($input['nombre'])){
- $username = $input['email'];
- $password = $input['passw'];
- $name= $input['name'];
- if(!emailExists($email)){
- $salt = getSalt();
- $passwordHash = passw(concatPasswordWithSalt($password,$salt),PASSWORD_DEFAULT);
- //Query to register new user
- $insertQuery = "INSERT INTO users(email, name, passw, salt) VALUES (?,?,?,?)";
- if($stmt = $con->prepare($insertQuery)){
- $stmt->bind_param("ssss",$email,$name,$passwordHash,$salt);
- $stmt->execute();
- $response["status"] = 0;
- $response["message"] = "User created";
- $stmt->close();
- }
- }
- else{
- $response["status"] = 1;
- $response["message"] = "Email already in use";
- }
- }
- else{
- $response["status"] = 2;
- $response["message"] = "Missing mandatory parameters";
- }
- echo json_encode($response);
- ?>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement