728x90
반응형
http://www.example.com/index.html?name=john&email=john@gmail.com&contact=9877989898

Client Side: Below code is an HTML form with method=”get” for user to fill information.


<form action="#" method="get">
<input type="text" name="name" placeholder="Your Name"></input><br/>
<input type="text" name="email" placeholder="Your Email"></input><br/>
<input type="text" name="contact" placeholder="Your Mobile"></input><br/>
<input type="submit" name="submit" value="Submit"></input>
</form>

Server Side: Below code has PHP script where, $_GET associative array is used to receive sent information at server end.


<?php
if( $_GET["name"] || $_GET["email"] || $_GET["contact"])
{
echo "Welcome: ". $_GET['name']. "<br />";
echo "Your Email is: ". $_GET["email"]. "<br />";
echo "Your Mobile No. is: ". $_GET["contact"];
}
?>


Client Side: Below code is an  HTML form with method=”post” for user to fill information.


<form action="#" method="post">
....
</form>

Server Side: Below code has PHP script where, $_POST associative array  is used to receive sent information at server end.


<?php
if( $_POST["name"] || $_POST["email"] || $_POST["contact"])
{
echo "Welcome: ". $_POST['name']. "<br />";
echo "Your Email is: ". $_POST["email"]. "<br />";
echo "Your Mobile No. is: ". $_POST["contact"];
}
?>

Query string , generated by Post  method never appears in address bar i.e. it is hidden for the user therefore, we can use this method for sending sensitive information to server. Moreover, we can make use of this method to send binary data to the server without any restrictions to data size.

 

In our example, we allow user to choose a method via radio button and this value is assigned to form’s method attribute.


$("input[type=radio]").change(function(){
var method = $(this).val();
$("#form").attr("method", method);   // Assigns Method Type From Radio Button
});


728x90
반응형

'Web Programming > php' 카테고리의 다른 글

php file_get_contents()  (0) 2018.09.05
php new line to br nl2br()  (0) 2018.09.05
PHP 문자열 길이 (strlen, mb_strlen 함수)  (0) 2018.09.04
php data types  (0) 2018.09.04
php include, require  (0) 2018.09.03

+ Recent posts