Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • $_GET and $_POST methods in php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 496
    Comment on it

    Explanation of GET and POST methods in php

    GET and POST are treated as $_GET and $_POST in php.
    These are superglobals, which means that they are always accessible.
    $_Get: This is used as an array of variables and passed to the current script with the URL parameters.

    $_POST: This method is used as a array of variables passed to the current scripts by a HTTP POST method.

    
    <!DOCTYPE HTML>
    <html>
    <body>
    
    <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
    Name: <input type="text" name="name"><br>
    E-mail: <input type="text" name="email"><br>
    <input type="submit">
    
     <?php
    
    if(isset($_POST['name']) && isset($_POST['email'])){
      $name = $_POST['name'];
      $email = $_POST['email'];
      if($name == null)
      {
        echo "name not found";
      }
     else if ($email == null) {
       echo "email not found";
      }
      else echo $name . "<br>". $email; 
    }
    
    
    ?>
    </form>
    
    </body>
    </html>

    In the above code the php page will reload into the same page and taking the value in the form of post by HTTP POST methods.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: