unable to pass the value and get the response using GET meth
Posted: Sat Dec 12, 2015 8:02 am
Hi Friends,
I have two pages in my website index.php and trailtatus.php,when i pass the value from drop down to api pattern using php and json,it shows the trailstatus.php is empty page..
when i choose the train number and date in index.php then i press submit button it shows the empty result in the trailstatus.php page..kindly help me to resolve the problem.
our API Pattern will be lookks the below format:
API Pattern:
http://api.railwayapi.com/live/train/<t ... y/<apikey/
index.php
=================================================================
trailstatus.php
Thanks
Sathya
I have two pages in my website index.php and trailtatus.php,when i pass the value from drop down to api pattern using php and json,it shows the trailstatus.php is empty page..
when i choose the train number and date in index.php then i press submit button it shows the empty result in the trailstatus.php page..kindly help me to resolve the problem.
our API Pattern will be lookks the below format:
API Pattern:
http://api.railwayapi.com/live/train/<t ... y/<apikey/
index.php
Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<title>PNR Status </title>
<head>
<body>
<center>
<form action="trailstatus.php" method="get">
<tr>
<td> Train Number:</td>
<td><input type="text" name ="train number"> </td> </br>
</tr>
<tr>
<td> Select Date:</td>
<td><select>
<option value="today"><?php echo date('Ymd', strtotime("today")); ?></option>
<option value="tomorrow"><?php echo date('Ymd', strtotime("tomorrow")); ?></option>
<option value="yesterday"><?php echo date('Ymd', strtotime("yesterday")); ?></option>
</select></td>
</tr>
<tr>
<td></br>
Submit:
</td>
<td><input type="submit" name ="submit">
</td>
</form>
</center>
</body>
</html>=================================================================
trailstatus.php
Code: Select all
<!DOCTYPE html
<html
<body
<?php
$json = '';
if(isset($_GET['trainnumber'] && isset($_GET['doj'] )){
$searchParam1 = $_GET['trainnumber'];
$searchParam2 = $_GET['doj'];
$replacedStr = str_replace(" ","",$searchParam1);
$replacedStr1 = str_replace(" ","",$searchParam2);
$url = 'http://api.railwayapi.com/live/train/' $replacedStr.'/doj/' $replacedStr1.'/apikey/ididntnoticeipostedmyapikeybutrequinixremoveditthankyou';
$content = file_get_contents($url);
$json = json_decode($content, true);
}else{
echo "something went wrong, please notify to admin [support@livetrainrunningstatus.co.in]";
}
$station = $json['route'] ['station'];
$scharr = $json['route'] ['scharr'];
$actarr = $json['route'] ['actarr'];
$status= $json['route'] ['has_departed'] [0] ['latemin'];
?>
<table>
<tr>
<th>station</th>
<th>Sch.Arrival</th>
<th>Act.Arrival</th>
<th>Status/delay</th>
</tr>
<tr>
<td><?php echo $station;?></td>
<td><?php echo $scharr;?></td>
<td><?php echo $actarr;?></td>
<td><?php echo $status;?></td>
</tr>
</table>
</body
</html
Sathya