Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (47 sloc) 1.81 KB
//checking if the script received a post request or not
//Getting post data
$name = $_POST['name'];
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
//checking if the received values are blank
if($name == '' || $username == '' || $password == '' || $email == ''){
//giving a message to fill all values if the values are blank
echo 'please fill all values';
//If the values are not blank
//Connecting to our database by calling dbConnect script
//Creating an SQL Query to insert into database
//Here you may need to change the retrofit_users because it is the table I created
//if you have a different table write your table's name
//This query is to check whether the username or email is already registered or not
$sql = "SELECT * FROM test WHERE username='$username' OR email='$email'";
//If variable check has some value from mysqli fetch array
//That means username or email already exist
$check = mysqli_fetch_array(mysqli_query($con,$sql));
//Checking check has some values or not
//If check has some value that means username already exist
echo 'username or email already exist';
//If username is not already exist
//Creating insert query
$sql = "INSERT INTO test (name,username,password,email) VALUES('$name','$username','$password','$email')";
//Trying to insert the values to db
//If inserted successfully
echo 'successfully registered';
//In case any error occured
echo 'oops! Please try again!';
//Closing the database connection
echo 'error';
You can’t perform that action at this time.