Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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');
}
Comment

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 {
             ...............   
      }
Comment

PREVIOUS NEXT
Code Example
Php :: wp get user meta 
Php :: for loop in php 
Php :: check if session variable exists php 
Php :: php artisan serve specify ip 
Php :: how to allow cors through header in php 
Php :: laravel withtrashed 
Php :: php date and time 
Php :: log facade laravel 
Php :: laravel make migration controller resource mcr 
Php :: public laravel htaccess 
Php :: yii 1 clear cache 
Php :: how to delete image from aws using laravel 8 
Php :: how to connect to a database in php 
Php :: get yesterday date in php 
Php :: laravel updateorcreate 
Php :: pdo connexion 
Php :: default sort yii2 
Php :: group by laravel 
Php :: laravel number add 0 before 
Php :: php utf 8 sqlsrv 
Php :: wordpress on publish hook 
Php :: apache htaccess read from /public 
Php :: Error: Call to a member function addEagerConstraints() on null in file 
Php :: group routes in laravel 
Php :: get file each line in php 
Php :: Date and Time PHP Continued 
Php :: php configuration 
Php :: mysql timestamp format php 
Php :: strupper php 
Php :: wp_query limit 1 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =