I want to fetch data from government site, that has a login form and after user get logged in, the data are then displayed. I want to fetch those data into my site.
Here's what I am doing in index.html
and process.php
.
<form action="/post/process.php" method="post" id="form">
<input type="hidden" id="cboOpt" name="cboOpt" value="1">
<label for="txCno">Input Consumer No</label>
<input type="text" value="" id="txCno" name="txCno"><br><br>
<label for="cbSdiv">Select Division</label>
<select id="cbSdiv" name="cbSdiv">
<option value="0">Please Select</option>...<option value="7">Upper bazar</option>
</select><br><br>
<input type="hidden" value="Input K. No" name="txKno" id="txKno">
<input type="hidden" value="Input Mobile No" name="txMno" id="txMno">
<input type="hidden" value="Input Bill No" name="txBno" id="txBno">
<input type="submit" value="Submit" name="submit">
</form>
<?php
if(isset($_POST['submit'])) {
$cboOpt = $_POST['cboOpt'];
$txCno = $_POST['txCno'];
$cbSdiv = $_POST['cbSdiv'];
$txKno = $_POST['txKno'];
$txMno = $_POST['txMno'];
$txBno = $_POST['txBno'];
$postdata = http_build_query(
array(
'cboOpt' => $cboOpt,
'txCno' => $txCno,
'cbSdiv' => $cbSdiv,
'txKno' => $txKno,
'txMno' => $txMno,
'txBno' => $txBno
)
);
$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$response = file_get_contents("http://secure.urjamitra.in/urjamitra/onlinepay/", false, $context);
echo $response;
}
?>