This is php validation
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<h1>Regestration Form</h1>
<h4> * indicates must select </h4>
<?php
error_reporting(E_ALL ^ E_NOTICE);
$nameerror="";
$emailerror="";
$addresserror="";
$gendererror="";
$fileerror="";
$uploadfileerror="";
$hobbyerror="";
$stateerror="";
$cityerror="";
$usernameerror="";
$passworderror="";
$confirmpassworderror="";
$pc="";
$pwd = strip_tags(trim($_POST['password'])); //Value of Password Store
$conf_pwd = strip_tags(trim($_POST['confirm_password'])); //Value of Confirm Password Store
if (!empty($_POST['Submit']))
{
$namearray=array('name' =>$_POST['name']);
$fname=(trim($_POST['name']));
if ($fname=="")
{
$nameerror="please enter name";
}
$emailarray=array('email' =>$_POST['email']);
$femail=(trim($_POST['email']));
if ($femail=="")
{
$emailerror="please enter email";
}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $femail))
{
$invalidemail="please enter valid email id"."<br>";
}
$addressarray=array('address' =>$_POST['address']);
$faddress=(trim($_POST['address']));
if ($faddress=="")
{
$addresserror="please enter address";
}
$genderarray=array('m2'=>$_POST['m2']);
$fgender=(isset($_POST['m2']));
if($fgender=="")
{
$gendererror="please select gender";
}
$filearray=array('file'=>$_FILES['file']);
$ffile=(trim($_FILES['file']));
if ($ffile=="")
{
$fileerror="please upload file";
}
$hobbyarray=array('hobby'=>$_POST['hobby']);
$fhobby=(isset($_POST['hobby']));
if($fhobby=="")
{
$hobbyerror="please select hobby";
}
$statearray=array('state'=>$_POST['state']);
$fstate=(trim($_POST['state']));
if($fstate=="")
{
$stateerror="please select state";
}
$cityarray=array('city'=>$_POST['city']);
$fcity=(trim($_POST['city']));
if($fcity=="")
{
$cityerror="please select city";
}
$usernamearray=array('user_name'=>$_POST['user_name']);
$fusername=(trim($_POST['user_name']));
if($fusername=="")
{
$usernameerror="please enter user name";
}
$passwordarray=array('password'=>$_POST['password']);
$fpassword=(trim($_POST['password']));
if($fpassword=="")
{
$passworderror="please enter password";
}
$confirmpasswordarray=array('confirm_password'=>$_POST['confirm_password']);
$fconfirmpassword=(trim($_POST['confirm_password']));
if($fconfirmpassword=="")
{
$confirmpassworderror="please enter Confirm password";
}
if($pwd != $conf_pwd)
{
$pc="your password and confirm password do not match"."<br>";
}
// File Upload Valditation...
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/bmp")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] >20000)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("D:/Training/12.11.08/images/" . $_FILES["file"]["name"]))
{
$now = time();
$path_parts = pathinfo($_FILES["file"]["name"]);
$string="naresh";
$newtry=$path_parts['basename'].$string;
$imagestring=$_FILES["file"]["name"];
$shuffled = str_shuffle($imagestring);
move_uploaded_file($_FILES["file"]["tmp_name"],
"D:/Training/12.11.08/images/" .$newtry.$now.$shuffled.$_FILES["file"]["name"]);
echo "Image Stored in: " ."D:/Training/12.11.08/images/"."<br>".$newtry.$now.$shuffled. $_FILES["file"]["name"];
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"D:/Training/12.11.08/images/" . $_FILES["file"]["name"]);
echo "Image Stored in: " ."D:/Training/12.11.08/images/"."<br>". $_FILES["file"]["name"];
}
}
}
else
{
//echo "Invalid file"."<br>";
$infileerror="invalid file";
}
//file upload synapse code
}
?>
<?php
error_reporting(E_ALL ^ E_NOTICE);
$mainerror="";
if(
($nameerror=="") &&
($emailerror=="")&&
($addresserror=="")&&
($gendererror=="")&&
($hobbyerror=="")&&
($stateerror=="")&&
($cityerror=="")&&
($usernameerror=="")&&
($passworderror=="")&&
($confirmpassworderror=="")&&
($pc=="")&&
($fileerror=="")&&
($infileerror=="")&&
($invalidemail=="")
)
{
echo "<br>"."Name :{$namearray['name']}"."<br>";
echo "Email :{$emailarray['email']}"."<br>";
echo "Address :{$addressarray['address']}"."<br>";
echo "Gender :{$genderarray['m2']}"."<br>";
echo "File :{$filearray['file']}"."<br>";
echo "Hobby :{$hobbyarray['hobby']}"."<br>";
echo "State :{$statearray['state']}"."<br>";
echo "City :{$cityarray['city']}"."<br>";
echo "Username :{$usernamearray['user_name']}"."<br>";
echo "Password :{$passwordarray['password']}"."<br>";
echo "Confirm Password :{$confirmpasswordarray['confirm_password']}"."<br>";
}
else
{
$mainerror="Please correct bellow mention error and try again ! Thanks";
}
?>
<table>
<tr><td><font color="#CC0066" size="+2"><?php echo $mainerror; ?></font></td></tr><br />
<tr><td><font color="#FF0000" size="+1"><?php echo $pc; ?></font></td></tr><br />
<form method="POST" ENCTYPE="multipart/form-data" action="">
<tr>
<td> <b> Name : </b> </td>
<td><input name="name" type="text" id="name" maxlength="20" value="<?php echo $_POST['name'] ?>"/>*(Maxlength 20)</td>
<td> <font color="#FF0000" size="+1"><?php echo $nameerror; ;?></font></td>
</tr>
<tr>
<td><b> Email : </b> </td>
<td><input name="email" type="text" id="email" maxlength="20" value="<?php echo $_POST['email'] ?>" />*(Maxlength 20)</td>
<td> <font color="#FF0000" size="+1"><?php echo $emailerror; ;?></font></td>
<td> <font color="#FF0000" size="+1"><?php echo $invalidemail; ;?></font></td>
</tr>
<tr>
<td><b> address : </b> </td>
<td><input name="address" id="address" value="<?php echo $_POST['address'] ?>"/>*(Maxlength 40)</td>
<td> <font color="#FF0000" size="+1"><?php echo $addresserror; ;?></font></td>
</tr>
<tr>
<td><b> Gender : </b> </td>
<td><input type="radio" name="m2" value="Male" id="rdmale" <?php echo $_POST['m2'] ?>/>
Male
<input type="radio" name="m2" value="Female" id="rdfemale">
Female ( * )</td>
<td> <font color="#FF0000" size="+1"><?php echo $gendererror; ;?></font></td>
</tr>
<tr>
<td> <b>Upload Photo : </b> </td>
<td><input type="file" name="file" id="file" value=""/> *(Upload Only .jpg,.jpeg,.gif,.png,.bmp files)</td>
<td><font color="#FF0000" size="+1"><?php echo $fileerror; ;?></font></td>
<td><font color="#FF0000" size="+1"><?php echo $infileerror; ?></font></td>
</tr>
<tr>
<td><b> Hobby : </b> </td>
<td><input type="checkbox" name="hobby" value="cricket" id="chk1" <?php echo $_POST['hobby'] ?> />cricket
<input type="checkbox" name="hobby" value="football" id="chk2" />football
<input type="checkbox" name="hobby" value="rugby" id="chk3" />rugby
<input type="checkbox" name="hobby" value="other" id="chk4" />other *(Select Minimum 1) </td>
<td> <font color="#FF0000" size="+1"><?php echo $hobbyerror; ;?></font></td>
</tr>
<tr>
<td> <b> State : </b> </td>
<td><select name="state" id="state" >
<option value="<?php echo $_POST['state'] ?>" id="s0"> Select One </option>
<option id="s1">Gujarat</option>
<option id="s2">Maharashtra</option>
<option id="s3">MP</option>
</select> </td>
<td> <font color="#FF0000" size="+1"><?php echo $stateerror; ;?></font></td>
</tr>
<tr>
<td> <b> City : </b> </td>
<td><select size="5" name="city" id="city">
<option value="<?php echo $_POST['city'] ?>">ahmedabad</option>
<option id="c1">patan</option>
<option id="c2">surendranagar</option>
<option id="c3">ahmedabad</option>
<option id="c4">Mumbai</option>
<option id="c5">Rajkot</option>
<option id="c6">Wadhawan</option>
<option id="c7">Ratanpar</option>
</select>
*(Select Atleast 1)</td>
<td><font color="#FF0000" size="+1"><?php echo $cityerror; ;?></font></td>
</tr>
<tr>
<td> <b> User name : </b> </td>
<td><input type="text" name="user_name" value="<?php echo $_POST['user_name'] ?>" id="user_name" maxlength="15"/>*(Maxlength 15) </td>
<td> <font color="#FF0000" size="+1"><?php echo $usernameerror; ;?></font></td>
</tr>
<tr>
<td><b> Password : </b> </td>
<td><input type="password" name="password" id="password" maxlength="12"
value="<?php echo $_POST['password'] ?>"/>*(Maxlength 12)</td>
<td> <font color="#FF0000" size="+1"><?php echo $passworderror; ;?></font></td>
</tr>
<tr>
<td> <b> confirm password : </b> </td>
<td><input type="password" name="confirm_password" id="confirm_password" maxlength="12"
value="<?php echo $_POST['confirm_password'] ?>"/>*(Maxlength 12)</td>
<td> <font color="#FF0000" size="+1"><?php echo $confirmpassworderror; ;?></font></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="submit"/>
<input type="reset" value="Reset"/> </td>
</tr>
</form>
</table>
</body>
</html>