Skip to main content

Forms in PHP

Tutorial Title: Forms in PHP
Course: PHP
Instructor: Muhammad Samim




1. $_POST is a global super variable
2. It picks up the data in post forms

3. Declaring form
  • <form action=""></form> //Or in Bracket editor just type form and press tab button rest will be come automatically
4.Declaring input in form and some types of it
  • <input type="text">           //for text box
  • <input type="password"> //for password
  • <input type="submit">    //for submit button

5. Declaring placeholder in input inside form
  • <input type="text" placeholder="Email"> //Email will be displayed inside the textbox
  • <input type="password" placeholder="Password"> //Password will be displayed inside password box

6. Complete coding to understand

<?php       //It will not be executed unless we don't click or enter the submit button
if(isset($_POST["anyName"])) //isset is a function and $_POST is global associated array thats why we use isset and anyName is declared in submit input type's name="anyName"
{
    echo "It Has been clicked";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <form action="21form.php" method="post">  //21form.php is a page name to be directed
       <input type="text" placeholder="Email">
       <input type="password" placeholder="Password">
       <br>
       <input type="submit" name="anyName">  //name="anyName" is used to submit and post the data to global variable $_POST and anyName should be same in if condition and here
    </form>
 
</body>
</html>

Comments

Popular posts from this blog

External Page Submission/Submission to another page

Tutorial Title:   External Page Submission/Submission to another page Course: PHP Instructor: Muhammad Samim 1. Submitting action from one page to another page 2. First make one page with name page1.php <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>Document</title> </head> <body>      <form action="page2.php" method="post"> //It will direct from page1.php to page2.php           <br><input type="text" placeholder="Email" name="anyNameForEmail">     <br><input type="password" placeholder="Password" name="anyNameForPassword">     <br><input type="submit" name="click">    </form>   </body> </html> 3. Second make another file with name page2.php <?php if(isset($_POST["click"])){     $anyNameO...

Extracting Information from form

Tutorial Title:  Extracting Information from form Course: PHP Instructor: Muhammad Samim 1. <?php if(isset($_POST["anyName"])) { $anyNameOfVariableForEmail = $_POST["anyNameForEmail"]; //Now because of it email must be typed otherwise it will not work $anyNameOfVariableForPassword = $_POST["anyNameForPassord"];//Now because of it password must be typed otherwise it will not work echo $anyNameOfVariableForEmail; //It will display the email echo $anyNameOfVariableForPassword; //It will display the password } ?> <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>Document</title> </head> <body>      <form action="21form.php" method="post">        <input type="text" placeholder="Email" name="anyNameForEmail">        <input type="password" placeholder="...