I am able to retrieve information using GET but I want help to post data.
I have my sample application, where I should login to get access to other details. There is another page in the application which does not require login.
Login needs three parameters
Code: Select all
1. txtUserName - a username
2. txtPassword - a password
3. subAuthentication - submitIf username and password are not available, we can use home page for trial purposes.
Here is the code...This file needs Request.php from the package and request.php requires PEAR.php, Socket.php, URL.php for your reference...
Code: Select all
<?php
/**
* This will grab a webpage and display it
*/
include('../Request.php');
$req = &new HTTP_Request("http://raghavan20.100webcustomers.com/authentication.php");
$req->addPostData("txtUserName", "raghavan20", false);
$req->addPostData("txtPassword", "visitor", false);
$req->addPostData("subAuthentication", "submit", false);
$req->sendRequest(true);
print_r($req->getResponseHeader());
print_r($req->getResponseCookies());
//$req->addCookie();
$req->setURL("http://raghavan20.100webcustomers.com/viewBlog.php");
$req->addRawQueryString("action=viewBlog&blogId=1", false);
echo "<br />";
print_r($req->_url);
echo "<br />";
$req->sendRequest(true);
print_r($req->getResponseHeader());
echo $req->getResponseBody();
?>