<?php
|
<?php
|
$conn = pg_connect("dbname=bus user=postgres password=snmc");
|
$conn = pg_connect("dbname=bus user=postgres password=snmc");
|
if (!$conn) {
|
if (!$conn) {
|
echo "An error occured.\n";
|
echo "An error occured.\n";
|
exit;
|
exit;
|
}
|
}
|
print_r($_REQUEST);
|
print_r($_REQUEST);
|
$reverse=$_REQUEST["reverse"];
|
$reverse=$_REQUEST["reverse"];
|
$from=$_REQUEST["from"];
|
$from=$_REQUEST["from"];
|
$to=$_REQUEST["to"];
|
$to=$_REQUEST["to"];
|
$routes=$_REQUEST["routes"] ;
|
$routes=$_REQUEST["routes"] ;
|
$points=$_REQUEST["between_points"];
|
$points=$_REQUEST["between_points"];
|
$sql = "INSERT INTO between_stops (fromLocation, toLocation, points, routes) VALUES('$from','$to','$points','$routes')";
|
$sql = "INSERT INTO between_stops (fromLocation, toLocation, points, routes) VALUES('$from','$to','$points','$routes')";
|
$result = pg_query($conn, $sql);
|
$result = pg_query($conn, $sql);
|
if (!$result) {
|
if (!$result) {
|
echo("Error in SQL query: " . pg_last_error() ."<br>\n");
|
echo("Error in SQL query: " . pg_last_error() ."<br>\n");
|
}
|
}
|
if ($reverse === "on") {
|
if ($reverse === "on") {
|
$points = implode(";",array_reverse(explode(";",$points))); |
$p = implode(";",array_reverse(explode(";",$points))).";"; |
|
$points = str_replace(";","",$p,1); |
$sql = "INSERT INTO between_stops ( toLocation, fromLocation, points, routes) VALUES('$from','$to','$points','$routes')";
|
$sql = "INSERT INTO between_stops ( toLocation, fromLocation, points, routes) VALUES('$from','$to','$points','$routes')";
|
$result = pg_query($conn, $sql);
|
$result = pg_query($conn, $sql);
|
if (!$result) {
|
if (!$result) {
|
echo("Error in SQL query: " . pg_last_error() ."<br>\n");
|
echo("Error in SQL query: " . pg_last_error() ."<br>\n");
|
}
|
}
|
}
|
}
|
flush();
|
flush();
|
|
|
?>
|
?>
|
|
|