1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php $conn = pg_connect("dbname=bus user=postgres password=snmc"); if (!$conn) { echo "An error occured.\n"; exit; } print_r($_REQUEST); $reverse=$_REQUEST["reverse"]; $from=$_REQUEST["from"]; $to=$_REQUEST["to"]; $routes=$_REQUEST["routes"] ; $points=$_REQUEST["between_points"]; $sql = "INSERT INTO between_stops (fromLocation, toLocation, points, routes) VALUES('$from','$to','$points','$routes')"; $result = pg_query($conn, $sql); if (!$result) { echo("Error in SQL query: " . pg_last_error() ."<br>\n"); } if ($reverse === "on") { $points = implode(";",array_reverse(explode(";",$points))); $sql = "INSERT INTO between_stops ( toLocation, fromLocation, points, routes) VALUES('$from','$to','$points','$routes')"; $result = pg_query($conn, $sql); if (!$result) { echo("Error in SQL query: " . pg_last_error() ."<br>\n"); } } flush(); ?> |