By 08/04/2016

What Is Html Form Get Method In PHP?

  • When you create a html form it has an attributes called “method=get” which helps to pass or transmits user data to PHP server.
  • Unlike post method, Mostly method="get" transmits minimal user data to PHP server.
  • The method="get" has many disadvantages such as: when you post your information over on a website it becomes visible in browser’s URL bar which can be easily stolen or read by someone.
  • The method="get" is lightweight because it stores the transmitted data in browser’s URL and that data is called query string.
  • While working on a web project some time you use method="get" as per your requirement.
  • If you have some personal information such as credit card number, contact number etc don’t use get method.
  • Never use get method with your html forms.
  • In PHP the recommended use of get method is with hyper links, if you want to pass user information to different pages and at this time get method is used automatically.
  • The $_GET['control_name'] PHP’s super global array┬áis used to fetch a value sent by get method.

Example: Use Get Method With A Html Form

<!Doctypes html>
 <html>
 <head>
 <title>Html Form Get Method In PHP</title>
 </head>
 
 <body>
 <?php 
 if(isset($_GET['btn_submit'])) {
 $user_name = $_GET['user_name'];
 $contact = $_GET['contact'];
 
 echo "Name is: " . $user_name . "<br>";
 echo "Contact: " . $contact;
 }
 ?>
 <form method="get" action="">
 <input type="text" name="user_name" placeholder = "Enter Name"> <br><br>
 <input type="text" name="contact" placeholder = "Enter Contact"> <br>
 
 <button type="submit" name="btn_submit"> Submit </button>
 </form>
 </body>
 </html>

Example: Use Get Method With Html Hyperlink

<!Doctypes html>
 <html>
 <head>
 <title>Get Method With Html Hyperlink</title>
 </head>
 
 <body>
 <?php 
 if(isset($_GET['user_name'])) {
 $user_name = $_GET['user_name'];
 
 echo "Name is: " . $user_name . "<br>";
 }
 ?>
 
 <form method="get" action="">
 <a href = "?user_name=<?php echo 'Albert';?>" name="user_name"> View name </a>
 </form>
 </body>
 </html>






Posted in: HTML, PHP, Solutions

Comments are closed.

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .