-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddCarShare.php
27 lines (21 loc) · 1.05 KB
/
addCarShare.php
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
<?php
require_once('functions.php');
connectdb();
$connection = mysqli_connect('localhost:2023', 'root', '', 'carpool'); // Replace with your database credentials
$userid = $_POST["uid"];
$from = $_POST["from"];
$to = $_POST["to"];
$cid = $_POST["cid"];
$query = 'SELECT * FROM offers WHERE id="' . $cid . '"';
$result = mysqli_query($connection, $query) or die("error!!!" . mysqli_error($connection));
$row = mysqli_fetch_array($result);
$timestamp = date("Y-m-d H:i:s");
$sender = $row["uid"];
// pooler waiting for approval from owner
$query = 'INSERT INTO notifications (sender, receiver, type, cid, timestamp) VALUES("' . $userid . '","' . $userid . '","4","' . $cid . '","' . $timestamp . '")';
$result = mysqli_query($connection, $query) or die("error23!");
// sent for approval to car owner
$query = 'INSERT INTO notifications (sender, receiver, type, cid, timestamp) VALUES("' . $userid . '","' . $sender . '","1","' . $cid . '","' . $timestamp . '")';
$result = mysqli_query($connection, $query) or die("error!45!");
header("Location: index.php?success=1");
?>