<?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=pg_escape_string($_REQUEST["from"]); |
$to=$_REQUEST["to"]; |
$to=pg_escape_string($_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") {
|
$ep = explode(";",$points);
|
$ep = explode(";",$points);
|
$epr = array_reverse($ep);
|
$epr = array_reverse($ep);
|
$p = implode(";",$epr).";";
|
$p = implode(";",$epr).";";
|
$pointsString = substr($p,1);
|
$pointsString = substr($p,1);
|
$sql = "INSERT INTO between_stops ( toLocation, fromLocation, points, routes) VALUES('$from','$to','$pointsString','$routes')";
|
$sql = "INSERT INTO between_stops ( toLocation, fromLocation, points, routes) VALUES('$from','$to','$pointsString','$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();
|
|
|
?>
|
?>
|
|
|