Created
November 6, 2020 02:24
-
-
Save phpfiddle/60c7bd17d67b9a95feef22b7a2590f26 to your computer and use it in GitHub Desktop.
[ Posted by Arizan Misbah ] php learning register
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "dbcon.php"; | |
$json = file_get_contents('php://input'); | |
$obj = json_decode($json, true); | |
$username = $obj['username']; | |
$password = $obj['password']; | |
$email = $obj['email']; | |
$query = "SELECT *FROM user where email = '($email)'"; | |
$query_output = mysqli_query($conn, $query); | |
$count = mysqli_num_rows($query_output); | |
if($count == 1) { | |
$arr = array("result"=>"email_already_present"); | |
echo json_encode($arr); | |
}elseif ($count==0) { | |
$query1 = "INSERT INTO 'user'('email', 'password', 'username') VALUES ('{$email}', '{password}', '{$username}')"; | |
$query_output1 = mysqli_query($conn, $query1); | |
$arr = array('result'=>'ok'); | |
echo json_encode($arr); | |
}else { | |
$arr = array('result'=>'fail'); | |
echo json_encode($arr); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment