jeudi 29 septembre 2016

how can I add a condition that will display an error if the username already taken or exist

how can I add a condition that will display an error if the username already taken or exist please help me :(

how can I add a condition that will display an error if the username already taken or exist please help me :(

how can I add a condition that will display an error if the username already taken or exist please help me :(

how can I add a condition that will display an error if the username already taken or exist please help me :(

This is my code

<?php
include '../connect.php';
?>

<?php
if(isset($_POST['register'])){

$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$bday = $_POST['bday'];
$contact = $_POST['contact'];
$address = $_POST['address'];
$licenseno = $_POST['licenseno'];
$gender = $_POST['gender'];
$picture = $_POST['picture'];
$avail = $_POST['availability'];

if(empty($username)||empty($email)||empty($password)||empty($password2)||empty($fname)||empty($lname)||empty($bday)||empty($contact)||empty($address)||empty($licenseno)||empty($gender)){
    $msg="*PLEASE FILL IN REQUIRED FIELDS*";
    header('Location:RegisterT.php?msg='.$msg.'');
}
else{

     if($password != $password2){
         $msg="Password Mismatch!";
         header('Location:registerT.php?msg='.$msg.'');
         }
     else{

         mysql_query("INSERT INTO therapist (`id`, `username`, `email`, `password`, `fname`, `lname`, `bday`, `contact`, `address`, `licenseno`, `gender`, `picture`, `about`, `availability` )VALUES
         ('', '$username','$email','$password','$fname','$lname','$bday','$contact','$address','$licenseno','$gender','default.jpg','Currently no information to show','Available')");
         $msg="Registration Successful";
         header('Location:LoginT.php?msg='.$msg.'');

    }
}

}

?>

Aucun commentaire:

Enregistrer un commentaire