Answers for "how to check user already exists in php"

PHP
0

how to check if username already exists in php

$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$email = $_POST["email"];
$pass = $_POST["password"];

$check_email = mysqli_query($conn, "SELECT Email FROM crud where Email = '$email' ");
if(mysqli_num_rows($check_email) > 0){
    echo('Email Already exists');
}
else{
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $result = mysqli_query($conn, "INSERT INTO crud (Firstname, Lastname, Email, Password) VALUES ('$firstname', '$lastname', '$email', '$pass')");
}
    echo('Record Entered Successfully');
}
Posted by: Guest on April-25-2021
0

how to check user already exists in php

$sql = "SELECT username FROM table_name WHERE username='{$username}'";
$result = mysqli_query($con,$sql) or die("Query unsuccessful") ;
      if (mysqli_num_rows($result) > 0) {
        echo "Username is already exist";
      } else {
             ...............   
      }
Posted by: Guest on January-11-2021

Code answers related to "how to check user already exists in php"

Browse Popular Code Answers by Language