I have 2 files on a web server in the same directory: post.php and receive.php
The post.php file posts a username and password. The receive.php receives the username and password, and prints them out.
The receive.php file looks like this:
<?php
$user=$_POST["user"];
$password=$_POST["password"];
echo("The Username is : ".$user."<br>");
echo("The Password is : ".$password."<br>");
?>
I have this code for the post.php:
<?php
$r = new HttpRequest('http://localhost/receive.php', HttpRequest::METH_POST);
$r->addPostFields(array('user' => 'mike', 'password' => '1234'));
try {
echo $r->send()->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
I tried various different ways of coding the post.php file, but none of them worked. I also tried following some tutorials online, but that didn't work either. I'm a PHP noob, please help!!