get post data in php code example
Example 1: php post
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
Name: <input type="text" name="fname">
<input type="submit">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['fname'];
}
?>
Example 2: php if $_POST
if( isset($_POST['fromPerson']) )
{
$fromPerson = '+from%3A'.$_POST['fromPerson'];
echo $fromPerson;
}
if (!empty($_POST))
{
$fromPerson = '+from%3A'.$_POST['fromPerson'];
echo $fromPerson;
}
Example 3: php get
<form method="GET">
<input type="text" name="someName">
//The Name Attribute will be put into the _GET inside of php
<input type="submit" value="Submit">
</form>
<?php
$var = $_GET("someName");
echo ($var);
?>