3/22/15

FORM GET Method


GET method is unsecured method because it display all information on address bar/ url.

By default method is get method. Using GET method limited data sends. GET method is faster way to send data.

Enter your name and click on submit button.

in the given example user has to enter his/her name in text box, after entering the input he/she has to click on submit to display the name entered by him/her.
Eg i
<html>
 <head>
  <?php
   echo $_GET['n'];  
  ?> 
  <title>get_browser</title></head>
 <body bgcolor="sky color">
  <form method="GET">
   <table border="1" bgcolor="green">
    <tr>
     <td>Enter your name</td>
     <td><input type="text" name="n"/></td>
    </tr>
    <tr>
     
     <td colspon="2" align="center">
     <input type="submit" value="show my name"/></td>
    </tr>
    
   </table>
  </form>
 </body>
</html>
Output abhishek
Enter your name  
In the given above example:
user entered the name inside the text box “Abhishek”, after entering the name he clicked on submit button
and can see the output of the program means Abhishek.
user can check the input given by the user shows inside the url because get method.

Enter two number and print the sum of given numbers.

Eg ii
<html>
 <head>
  <title>get_browser</title>
  
  <?php
  error_reporting(1);
  $x=$_GET['f'];
  $y=$_GET['s'];
  $z=$x+$y;
  echo "Sum of two number = ".$z;
  ?>
 </head>
 <body bgcolor="sky color">
  <form method="GET" >
   <table border="1" bgcolor="green">
    <tr>
     <td>Enter your first number</td>
     <td><input type="text" name="f"/></td>
    </tr>
    <tr>
     <td>Enter your second number</td>
     <td><input type="text" name="s"/></td>
    </tr>
    <tr align="center">
     
     <td colspon="2" >
     <input type="submit" value="+"/></td>
    </tr>
    
   </table>
  </form>
 </body>
</html>

Output :  Sum of two number = 500
Enter your first number
Enter your second number
In the given above example:
user has to enter the first number, second number
after given the input click on “+” button, and check the output means the sum of two numbers.
can also see the input given by him/her displays on addressbar(url).
Eg iii
 <?php
  error_reporting(1);
  $id=$_GET['id'];
  $pass=$_GET['pass'];
  if(isset($_GET['signin']))
  {
   if($id=="Deep" && $pass=="Deep123")
   {
   header('location:http://truetech4.blogspot.in/');
   }
   else
   {
  echo "<font color='red'>Invalid id or password</font>";
   }
  }
 ?>
 
 <body>
 <form method="get">
  <table border="1" align="center">
   <tr>
    <td>Enter Your Id</td>
    <td><input type="text" name="id"/>
    </td>
   </tr>
   <tr>
    <td>Enter Your Password</td>
    <td><input type="password" name="pass"/>
    </td>
   </tr>
   <tr>
    <td><input type="submit" name="signin" value="SignIn"/>
    </td>
   </tr>
  </table">
  </form>
 </body>
 
 Output : Redirect on truetech4.blogspot.in (check url)
 Enter your id       
 Enter your password 
   
In the given above example:
user has to enter the username and the password,
after entering the valid username and password click on “SignIn” button, if the user is valid the header() function redirects on next page “http://truetech4.blogspot.in/” otherwise show an error message Invalid id or password

Related Posts:

  • PHP string functions PHP has over 75 built-in String manipulation functions, supporting operations ranging from string repetition and reversal to comparison and sear… Read More
  • PHP Conditional Statement PHP lets programmers evaluate different conditions during of a program and take decisions based on whether these conditions evaluate to tru… Read More
  • PHP Operators Variables are simply containers for information. In order to do anything useful with them, you need Operators .Operators ar… Read More
  • PHP Array All the variables you have used have held only a single value. Array variables are “special” because they can hold more than on… Read More
  • PHP Numeric Don’t think that PHP’s power is limited to strings only. The language has over 50 built-in functions for working with numbers, ranging from si… Read More

0 comments:

Post a Comment

FIND US ON FACEBOOK

FIND US ON Twitter