Skip to content

Instantly share code, notes, and snippets.

@mridulsharma612
Created March 14, 2019 18:06
Show Gist options
  • Select an option

  • Save mridulsharma612/f28583d885c3effa37a61638a57a6d02 to your computer and use it in GitHub Desktop.

Select an option

Save mridulsharma612/f28583d885c3effa37a61638a57a6d02 to your computer and use it in GitHub Desktop.
<?php
require_once "connection.php";
//print_r($_POST);
//exit();
if (isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['email']) && isset($_POST['username']) && isset($_POST['password']) && isset($_POST['confirmpassword'])) {
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
$sql = "SELECT email FROM users WHERE email='$email'";
$resultset = mysqli_query($conn, $sql) or die("database error:" . mysqli_error($conn));
$row = mysqli_fetch_assoc($resultset);
if (!$row['email']) {
$sql = "INSERT INTO users(`firstname`, `lastname`, `email`,`username`,`password`,`confirmpassword`) VALUES ('$firstname', '$lastname', '$email','$username','$password','$confirmpassword')";
mysqli_query($conn, $sql) or die("database error:" . mysqli_error($conn) . "qqq" . $sql);
echo "registered";
} else {
echo "1";
}
} else {
echo 'Invalid Request';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment