Skip to main content

PHP Form Validation In Bangla





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>&nbsp;</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

Popular posts from this blog

Factorial Using PHP In Bangla

Code: <form action="" method="post"> Enter Number : <input type="text" name="num" /> <input type="submit" name="submit" value="Submit" /> </form> <?php if(isset($_POST['submit'])){ $num = $_POST['num']; $fact = 1; for($i=2;$i>=1;$i--){ $fact *= $i; } print "The Factorial is: ".$fact; } ?>

PHP File Read Using fgets function In Bangla

Code: <?php class file { function file_read(){ $fp = fopen('student.txt','r'); while(!feof($fp)){ print fgets($fp); print "<br />"; } } } $file = new file();     $file->file_read(); ?>