Code:
<form action="" method="post">
<table>
<tr>
<td>User Name</td>
<td>
<input type="text" name="uname" />
</td>
</tr>
<tr>
<td>Password</td>
<td>
<input type="password" name="pass" />
</td>
</tr>
<tr>
<td>Email</td>
<td>
<input type="text" name="email" />
</td>
</tr>
<tr>
<td>Hobby</td>
<td>
<input type="checkbox" name="hb[]" value="Sleep" />Sleep
<input type="checkbox" name="hb[]" value="Eat" />Eat
<input type="checkbox" name="hb[]" value="Travel" />Travel
<input type="checkbox" name="hb[]" value="Study" />Study
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Submit" name="submit" /></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])){
$uname = $_POST['uname'];
$pass = @$_POST['pass'];
$email = @$_POST['email'];
$flag = 1;
$input="";
if(strlen($uname)==0){
print "Enter User Name<br />";
$flag = 0;
}
else {
$input .= "Your Name: ".$uname."<br />";
}
if(strlen($pass)==0){
print "Enter Password<br />";
$flag = 0;
}
else if(strlen($pass)<6 || strlen($pass)>8){
print "Password Should be within 6 to 8 character<br />";
$flag = 0;
}
else {
$input .= "Your Password: ".$pass."<br />";
}
if(strlen($email)==0){
print "Enter Email<br />";
$flag = 0;
}
else if(!filter_var($email,FILTER_ VALIDATE_EMAIL)){
print "Enter valid Email<br />";
$flag = 0;
}
else {
$input .= "Your Email: ".$pass."<br />";
}
if(count(@$_POST['hb'])==0){
print "Select Hobby<br />";
$flag = 0;
}
else {
$h1;
foreach(@$_POST['hb'] as $h){
@$h1 .= $h." ";
}
$input .= "Your Hobby: ".$h1."<br />";
}
if($flag==1){
print $input;
}
}
?>
Comments
Post a Comment