Amazon Ads

How to make a form submission system in HTML & PHP

Hello I am Abthahi Ahmed Rifat. Today, I will show How to make a form submission system using HTML & PHP

At first we need to create a form in HTML using form tag. See example bellow ...

PHP Coding Format


Form.html File

Firstly we create a form.html or index.html file and write this code in this file.
<html>
<head>
<title>Simple Form System using HTML & PHP</title>
</head>
<body>

    <form action="submit.php" method="POST">
        <input name="email" type="email" placeholder="Enter Your Email here..">
        <input name="password" type="password" placeholder="Enter Your                     password     here..">
        <button type="submit">Submit</button>
    <form>

</body>
</html>

Submit.php File

After writing the html code, we need to create a new file called submit.php as it as the action attribute's value.

Notice : To run a PHP code you need to setup a local php server in your computer. Because php program not work without php server.   

<?php
    if(isset($_POST['email'] && $_POST['password']){
        $email = $_POST['email'];
        $password = $_POST['password'];
        echo "Email : ".$email;
        echo "Password : ".$password;
    }else{
        header('location : form.html');
    }
?>
this is it.

Using this program when you enter your password and email in the input fields on the form and hit submit button then it will navigate to the PHP file and show the email and password.



Comments