Sir, i am using these codes
<?php
$myusername="";
$mypassword="";
$myemail="";
$mymobile="";
$mycountry="";
$mycity="";
$myage="";
$mygender="";
$myphoto="";
if(isset($_POST['save'])){
require_once("connect.php");
function clean($str){
$cstr=trim($str);
$cstr=addslashes($str);
$cstr=htmlspecialchars($str);
return $cstr;
}
$myusername=clean($_POST['username']);
$mypassword=clean($_POST['password']);
$myemail=clean($_POST['email']);
$mymobile=clean($_POST['mobile']);
$mycountry=clean($_POST['country']);
$mycity=clean($_POST['city']);
$myage=clean($_POST['age']);
if(empty($myusername))
{
echo ('<script>alert("User name must not be empty")</script>');
echo '<script>document.getElementById("form1.username").focus()</script>';
}
elseif (empty($mypassword))
{
echo ('<script>alert("Password must not be empty")</script>');
}
elseif (empty($email))
{
echo ('<script>alert("Email must not be empty")</script>');
}
elseif(empty($mymobile))
{
echo ('<script>alert("Mobile must not be empty")</script>');
}
else
{
$query="SELECT * FROM admin where username $myusername";
$result=mysqli_query($con,$query)or die ("Error". mysqli_error($con)) ;
$count=mysqli_num_rows($result);
if($count==1)
{
echo ('<script>alert("This user name is already exists, please select an other")</script>');
}
else
{
$query = "INSERT INTO admin (username,password ,email,mobile,country,city,age ,photo )
VALUES ($myusername,$mypassword ,$myemail, $myemail, $mymobile,$mycity,$myage ,$myphoto)";
$result=mysqli_query($con, $query) or die (mysqli_error());
if(!$result)
{
echo ('<script>alert("User name is not registered")</script>');
}
}
}
}
?>
I fill all textboxes but it allways run this line:
echo ('<script>alert("Email must not be empty")</script>');
What I am doing wrong?