Skip to main content

FormValidation

<?php

?>
<form action="valid2.php" method="post" enctype="multipart/form-data"style="background-color: pink;">
   
    <center> <h1>Student Registration Form</h1></center>
   
    <table align="center">
        <tr>
            <td>Name :</td>
            <td> <input type="text" name="uname"></td>
        </tr>
       <tr>
            <td>E_mail</td>
            <td><input type="text" name="email"></td>
       
        </tr>
        <tr>
            <td>password :</td>
            <td> <input type="password" name="pass"></td>
        </tr>
        <tr>
            <td>Gender :</td>
         
            <td>Male<input type="radio" name="sex"></td>
         
          <td>Female<input type="radio" name="sex"></td>
        </tr>
       
        <tr>
            <td>Division </td>
            <td><select name="div">
                            <option value="">pleae select</option>
                            <option value="Dhaka">Dhaka</option>
                            <option value="Rajshahi">Rajshahi</option>
                            <option value="Dinajpur">Dinajpur</option>
                </select></td>
        </tr>
       
       
        <tr><td>Education :</td>
            <td>SSC<input type="checkbox" name="ssc" value="ssc"></td>
                <td>HSC <input type="checkbox" name="hsc" value="hsc"></td>
           
        <tr>
            <td><input type="submit" name="submit" value="submit"</td>
        </tr>
    </table>
   
   
</form>







Part 2



<?php

$submit=$_POST['submit'];
$name=$_POST['uname'];
$email=$_POST['email'];
$Password=$_POST['pass'];
$gender=$_POST['sex'];
$division=$_POST['div'];
$ssc=$_POST['ssc'];
$hsc=$_POST['hsc'];

$regexp = "^[A-z0-9]+@[A-z0-9]+\.[A-z]{2,4}$";

$regexpas = "^[A-z0-9]{8,10}$";

if(empty($name)){
  echo"Please enter your name";
 
    }elseif(!eregi($regexp, $email)){
      echo "Please enter a valid email.<br/>";
     
    }elseif(!eregi($regexpas, $Password)){
      echo "Please enter a valid password";
     
  }elseif(empty ($sex)) {
   echo"Please select gender";
 
}elseif(empty ($div)) {
   echo"Please select division";
 
  }elseif(empty ($ssc)) {
   echo"Please select SSC";
 
   }elseif(empty ($hsc)) {
   echo"Please select HSC";
 
}else{
    echo"<center><p><h1>Thanks for your information</h1></p></center>";
}
?>


<!--<!Doctype HTML>
<html>
    <head>
        <title></title>
    </head>
   
    <body>
       
    <center> <h1>Student Registration Form</h1></center>
       
<table align="center">
   
    <tr>
        <td>User Name : </td>
        <td><?php echo $name=$_POST['uname']?></td>
       
    </tr>
   
    <tr>
       
        <td>E_mail : </td>
        <td><?php echo $Password=$_POST['email']?></td>
       
    </tr>
   
    <tr>
       
        <td>Password : </td>
        <td><?php echo $Password=$_POST['pass']?></td>
       
    </tr>
   
    <tr>
        <td>Gender : </td>
        <td><?php echo $Gender_selection=$_POST['sex']?></td>
       
    </tr>
   
    <tr>
        <td>Education : </td>
        <td><?php echo $education=$_POST['ssc']?></td>
       
    </tr>
   
    <tr>
        <td>Education : </td>
        <td><?php echo $education=$_POST['hsc']?></td>
       
    </tr>
   
    <tr>
        <td>Division: </td>
        <td><?php echo $division=$_POST['div']?></td>
       
    </tr>
    <tr>
        <td></td>
        <td></td>
    </tr>
</table>
       
    <center><a href="formvalidation.php">Go to Home Page</a></center>
   
   
    </body>
</html>-->

Comments

Popular posts from this blog

IDB HTML MCQ

Questions: 1. A webpage displays a picture. What tag was used to display that picture? a. picture b. image c. img d. src 2. <b> tag makes the enclosed text bold. What is other tag to make text bold? a. <strong> b. <dar> c. <black> d. <emp> 3. Tags and test that are not directly displayed on the page are written in _____ section. a. <html> b. <head> c. <title> d. <body> 4. Which tag inserts a line horizontally on your web page? a. <hr> b. <line> c. <line direction=”horizontal”> d. <tr> 5. What should be the first tag in any HTML document? a. <head> b. <title> c. <html> d. <document> 6. Which tag allows you to add a row in a table? a. <td> and </td> b. <cr> and </cr> c. <th> and </th> d. <tr> and </tr> 7. How can you make a bulleted list? a. <list> b. <nl> c. <ul> d. <ol> 8. Ho

Database Connection with PHP PDO MYSQL

PDO Connection MYSQLI // Create Connection with Pdo\ $dsn = "mysql:host=localhost; dbname=test;"; $db_user = "root"; $db_password = ""; try{     $conn = new PDO("$dsn", "$db_user","$db_password");    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);     // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);     echo "Connected"; }catch(PDOException $a){     echo "Connection Failed". $a->getMessage(); }