Example 1: php get

#Get Method and Post Data

Send data through get and Post

$_GET Example
============

if(isset($_GET['name'])){
echo htmlentities($_GET['name']);
//or
//$name = htmlentities($_GET['name']);
//echo $name
print_r($_GET);
}
?>
DOCTYPE html>
<html>
<head>
    <title>Get post websitetitle>
    head>
<body>
    <form method="GET action=get_post.php">
        <div>
            <label>Namelabel><br>
            <input type="text" name ="name">
        div>
        <div>
            <label>Emaillabel><br>
            <input type="text" name ="email">
        div>
        <input type="submit" value ="Submit">
    form>
body>
html>
================
$_POST Example
================

if(isset($_GET['name'])){
//echo htmlentities($_GET['name']);
//or
//$name = htmlentities($_GET['name']);
//echo $name
//print_r($_GET);
}

if(isset($_POST['name'])){
    $name = htmlentities($_POST['name']);
    echo $name;
    print_r($_POST);
}
?>
DOCTYPE html>
<html>
<head>
    <title>Get post websitetitle>
    head>
<body>
    <form method="POST" action="get_post.php">
        <div>
            <label>Namelabel><br>
            <input type="text" name ="name">
        div>
        <div>
            <label>Emaillabel><br>
            <input type="text" name ="email">
        div>
        <input type="submit" value ="Submit">
    form>
body>
html>
================
$_REQUEST Example  //another uncommon way to do it. This is not 
  //normally done this way
================

if(isset($_REQUEST['name'])){
    $name = htmlentities($_REQUEST['name']);
    echo $name;
    print_r($_REQUEST);
}

?>
DOCTYPE html>
<html>
<head>
    <title>Get post websitetitle>
    head>
<body>
    <form method="POST" action="get_post.php">
        <div>
            <label>Namelabel><br>
            <input type="text" name ="name">
        div>
        <div>
            <label>Emaillabel><br>
            <input type="text" name ="email">
        div>
        <input type="submit" value ="Submit">
    form>
body>
html>
================
$_SERVER['QUERY_STRING']  Example
================

echo $_SERVER['QUERY_STRING'];


?>
DOCTYPE html>
<html>
<head>
    <title>Get post websitetitle>
    head>
<body>
    <form method="POST" action="get_post.php">
        <div>
            <label>Namelabel><br>
            <input type="text" name ="name">
        div>
        <div>
            <label>Emaillabel><br>
            <input type="text" name ="email">
        div>
        <input type="submit" value ="Submit">
    form>
body>
html>

Example 2: php get

<form action="/" method="get">
  <input type="text" name="name">
  <br>
  <input type="submit">
form>

  echo $_GET["query"];
?>