PHP FORMS :

  • Hello guys ! In this tutorial we learn about PHP forms . That how PHP handles the form !
  • In simple HTML form we can see that how form works but in that kind of form we can use method to pass data by taking get or post method .
  • By taking it we can pass that form's data to PHP code and make PHP work on it !

PHP Example

Edit it yourself

<!DOCTYPE html>
<html>
<body>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PHP Form</title>
</head>
<body>
    <form method="get">
    <label>Username</label>
    <input type="text" name="unm" placeholder="username"/>
    <br>
    <label>Password</label>
    <input type="password" name="pass" placeholder="password"/>
    <br>
    <label>Submit</label>
    <input type="submit" name="submit" />  
    </form>
</body>
</html>

<?php 
    if(isset($_REQUEST['submit']))
    {
        $nm=$_REQUEST['unm'];
        $pass=$_REQUEST['pass'];

        echo "Hello ".$nm." Welcome ! ";
    }
   ?>

</body>
</html>

Output of PHP comment

Edit it yourself

Hello Web Welcome Web the stuff

  • Previous
  • Next