Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-type: application/json');
- header('Accept: application/json');
- $servername = "localhost";
- $username = "root";
- $password = "8357NOse";
- $dbname = "loginsystem";
- $conn = new mysqli($servername,$username,$password,$dbname);
- if($conn -> connect_error){
- header("HTTP/1.1 500 SHET IS BROKEN YOOOWWW (Bad connection, portal down)");
- die("Mother fucker (Ther server is down, we couldnt stablish the database connection)");
- }else{
- $uName = $_POST["uName"];
- $uPassword = $_POST["uPassword"];
- $uFirstName = $_POST["uFirstName"];
- $uLastName = $_POST["uLastName"];
- $sql = "SELECT * FROM Users WHERE '$uName' = username";
- $result = $conn -> query($sql);
- if($result->num_rows>0){
- header("HTTP/1.1 409 UserName already exsiste");
- die("Make original content son");
- }else{
- $sql = "INSERT INTO Users Values ('$uFirstName','$uLastName','$uName','$uPassword')";
- if($conn -> query($sql) === TRUE){
- $response = array("Firstname"=>$uFirstName,"Lastname"=>$uLastName,"username"=>$uName,"Password"=>$uPassword);
- echo json_encode($response);
- }else{
- header("HTTP/1.1 500 Coudln't make insert try later");
- die("Sorry son");
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement