Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user_name = $_POST['user_name'];
- $user_password = $_POST['user_password'];
- $phone_number = $_POST['phone_number'];
- $user_email = $_POST['user_email'];
- if (!empty($user_name) || !empty($user_password) || !empty($phone_number) || !empty($user_email)) {
- $host = "localhost";
- $dbUsername = "root";
- $dbPassword = "";
- $dbname = "loginsystem";
- //create connection
- $conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
- if (mysqli_connect_error()) {
- die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
- } else {
- $SELECT = "SELECT user_email From users Where user_email = ? Limit 1";
- $INSERT = "INSERT Into users (user_name, user_password, phone_number, user_email,) values(?, ?, ?, ?)";
- //Prepare statement
- $stmt = $conn->prepare($SELECT);
- $stmt->bind_param("s", $user_email);
- $stmt->execute();
- $stmt->bind_result($user_email);
- $stmt->store_result();
- $rnum = $stmt->num_rows;
- if ($rnum==0) {
- $stmt->close();
- $stmt = $conn->prepare($INSERT);
- *$stmt->bind_param("ssis", $user_name, $user_password, $phone_number, $user_email);*
- $stmt->execute();
- echo "New record inserted sucessfully";
- } else {
- echo "Someone already registered using this email";
- }
- $stmt->close();
- $conn->close();
- }
- } else {
- echo "All field are required";
- die();
- }
- ?>
Add Comment
Please, Sign In to add comment