-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaveTrip.php
More file actions
42 lines (33 loc) · 1.19 KB
/
Copy pathsaveTrip.php
File metadata and controls
42 lines (33 loc) · 1.19 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
session_start();
require_once 'config.php';
$name = $_REQUEST['tripname'];
$rating = $_REQUEST['rating'];
$cost = $_REQUEST['cost'];
$id = $_SESSION["usrid"];
//print ($cost);
//print ($rating);
//print ($name);
if($name != '' && $rating != '' && $cost != ''){
$sql = "INSERT INTO Trip (cost, rating, trip_name) VALUES ('".$cost."', '".$rating."', '".$name."')"; //--insert a Trip entity given the user input
if(mysqli_query($link, $sql)){
$sql = "INSERT INTO takes_a (traveller_ID, trip_ID) VALUES ($id, (SELECT LAST_INSERT_ID()))";
if (mysqli_query($link,$sql)){
echo '<script>alert("Success, saving you trip!")</script>';
print("Trip Saved");
} else{
echo '<script>alert("Error, could not handle request to Save Trip")</script>';
print("Failed");
}
} else {
echo '<script>alert("Error, could not handle request to Save Trip")</script>';
print("Failed");
}
}
else{
echo '<script>alert("Error, you must enter a value for each field in a trip")</script>';
}
// echo "<script>location.href='AddTrip.php'</script>";
$url = "AddTrip.php?usrid=".$id;
echo '<script>location.href="'.$url.'"</script>';
?>