daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest May 31st, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //File 1
  2.  
  3. <html>
  4. <head>
  5.     <title> Form</title>
  6. </head>
  7. <body>
  8.  
  9.     <form action="form_processing.php" method="post">
  10.         Username: <input type="text" name="username" value=""><br/>
  11.         password: <input type="password" name="password" value=""><br/>
  12.         <br/>
  13.         <input type="submit" name="submit" value="Submit">
  14.     </form>
  15.    
  16. </body>
  17. </html>
  18.  
  19.  
  20. //File 2
  21. <?php
  22.  
  23.     if(isset($_POST['submit'])){                 //checks if the submit button has been pressed
  24.         $username = $_POST['username'];
  25.         $password = $_POST['password'];
  26.     }else{                                           //When the submit button isn't pressed
  27.         $username = null;
  28.         $password = null;
  29.     }
  30.  
  31.  
  32. /*  //Alternative way to check form submission
  33.  
  34.     $username = isset($_POST['username'])?$_POST['username']: "";
  35.     $password = isset($_POST['password'])?$_POST['password']: "";
  36.    
  37. */
  38.     //the following codes are interpretion of the code above.
  39.    
  40.    
  41. /*  if(isset($_POST['username']))            //Detecting if the form has submitted the username value
  42.         $username = $_POST['username'];      //Gets the username through the superglobal POST array from index.php
  43.     else
  44.         $username = null;                    //Set Null as the default value when form date is not posted
  45.    
  46.    
  47.     if(isset($_POST['password']))            //Detecting if the form has submitted the password value
  48.         $password = $_POST['password'];      //Gets the password through the superglobal POST array from index.php
  49.     else
  50.         $password = null;                    //Set Null as the default value when form date is not posted
  51.    
  52. */
  53.    
  54.     echo $username."<br/>";              //prints the username
  55.     echo $password;                      //prints the password ;) Don't recommend to do in real life
  56.    
  57. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top