1<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
2 Name: <input type="text" name="fname">
3 <input type="submit">
4</form>
5<?php
6if ($_SERVER["REQUEST_METHOD"] == "POST") {
7 // do logic
8 $name = $_POST['fname'];
9}
10?>
1$response = httpPost("http://mywebsite.com/update.php",
2 array("first_name"=>"Bob","last_name"=>"Dillon")
3);
4
5//using php curl (sudo apt-get install php-curl)
6function httpPost($url, $data){
7 $curl = curl_init($url);
8 curl_setopt($curl, CURLOPT_POST, true);
9 curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
10 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
11 $response = curl_exec($curl);
12 curl_close($curl);
13 return $response;
14}
1if( isset($_POST['fromPerson']) )
2{
3 $fromPerson = '+from%3A'.$_POST['fromPerson'];
4 echo $fromPerson;
5}
6
7//Note: This resolves as true even if all $_POST values are empty strings
8if (!empty($_POST))
9{
10 // handle post data
11 $fromPerson = '+from%3A'.$_POST['fromPerson'];
12 echo $fromPerson;
13}
1$url = 'http://server.com/path';
2$data = array('key1' => 'value1', 'key2' => 'value2');
3
4// use key 'http' even if you send the request to https://...
5$options = array(
6 'http' => array(
7 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
8 'method' => 'POST',
9 'content' => http_build_query($data)
10 )
11);
12$context = stream_context_create($options);
13$result = file_get_contents($url, false, $context);
14if ($result === FALSE) { /* Handle error */ }
15
16var_dump($result);
17