Hi all ,
I am a new in PHP my code don't save information in db and password confirmation code doesn't work correctly
this is my simple code :
<?php
// decleration for varible
$name=$_POST['nameTxt'];
$username=$_POST['userNameTxt'];
$passTxt=$_POST['passTxt'];
$passConTxt=$_POST['passConTxt'] ;
$email=$_POST['email'];
$website=$_POST['website'];
$errors=0;
$submit=$_POST['btn_done'];
// connection to mysql
$con=mysqli_connect('localhost','root','root');
if(!$con){
die('Could not connection '.mysqli_error());
} //if $con
//select DB :
$db=mysqli_select_db('reg')
or die (mysqli_error());
// .....
if($submit){
if(!isset($name) || trim($name) == ''){
++$errors;
echo"Please enter the name <br>";
}//if name
// username if blank :
if(!isset($username) || trim($username) == ''){
++$errors;
echo'Please enter the username <br>';
}//if username
// email
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
// echo "email address is not valid <br>";
++$errors;
echo'Please enter a valid email<br>';
}// end if email
//duplicate email
//DETERMINE WHETHER THE EMAIL ADDRESS HAS ALREADY BEEN REGISTERED
$q = "SELECT id FROM store WHERE email = '$email'";
$result = mysql_query ($q);
if (mysql_num_rows($result) !== 0){
++$errors;
echo"email is already exists<br>";}
// website :
if(!filter_var( $website,FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED))
{ ++$errors;
echo'Please enter a valid website '.'<br>';
}
//end if website
////////////////////////////
///////////////////////////
// password :
if (strlen($_POST['passTxt']<6)){
++$errors;
echo'password should be more than 6 <br>';
}// if password
//password confirmation
elseif(0 !==strcmp($_POST['passTxt'], $_POST['passConTxt'])){
++$errors;
echo'password does not match <br>';
}//if password confirmation
elseif(0===$errors){
$query="insert into store values('','$name','$username','$passTxt','$passConTxt','$email','$website')";
$data=mysqli_query($query) or die(mysqli_error('ooooooooooooooooooooooooooo'));
if ($data){echo "DONE ! <br>";}
}//
}
//submit
Please suggest where i am making a mistakes!