WARNING! It is not my intension to promote any unauthorized content parsing. By using the script I have provided below, you are responsible for any copyright violations and damages it may caused.
Knowledge is Power, but it can also destroy many things, if the probable consequencies are not evaluated, before hand.
Remote Server form structures
Let say, the remote site have a form structure like this
<form action="remoteProcess.php" method="post">
<input type="text" name="first_name">
<input type="text" name="last_name">
<input type="text" name="roll_number">
<input type="submit" name="submit" value="submit">
</form>
Assuming that the remoteProcess.php" will return "records not available" on all faults, and return something if roll_number is valid one.
On your Server
This simple cURL implementation can parse the remote response to your site.
## first you need to process your own form in your site.
if(isset($_POST['submit'])&&(!empty($_POST['fname'])) && (!empty($_POST['sname'])) && (!empty($_POST['roll_number']))){
## You must add more form filtering before sending it to the remote site.
## if all is well, prepare your data for remote trasmission using cURL
## define remote form processor script
$location = 'http://remoteSite.com/remoteProcessor.php';
## define your user agent
$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $location );
$post_array = array(
"first_name"=>preg_replace('/[^a-zA-Z0-9 ]/s', ' ', $_POST['fname']),
"last_name"=>preg_replace('/[^a-zA-Z0-9 ]/s', ' ', $_POST['sname']),
"roll_number" => $_POST['roll_number'],
"submit" => "submit"
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);
## grab the response from the remote form processor
$response = curl_exec($ch);
## echo resonse or save as text or xml file. The choice are just too many to list. It is all up to you.
echo $response."<br/>";
## define what are you going to do if the remote processor sent out a fault response
if($response == "records not available"){
echo "roll_number is not valid";
## you can show your form here again default
}
}
It is my assumption that the remote site will have at least a reliable response on fault, otherwise this script is not going to work. We can still make it work, but requires another tidious coding just to eliminate the bad and faulty result returned by the remote server.
Lastly, If the cURL approach did not help much.. You can parse their RSS feeds or XML file if it is allowed.