-
Notifications
You must be signed in to change notification settings - Fork 0
/
Add_Rev_Script.php
42 lines (35 loc) · 1.05 KB
/
Add_Rev_Script.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
28
29
30
31
32
33
34
35
36
37
38
39
<?php
//require_once('lib/database.php');
$servername = "localhost:3306";
$username = "root";
$password = "";
$dbname = "restaurant_final";
$tbl_name1 = "review";
$tbl_name2 = "rating";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//Test connection
if (mysqli_connect_error()){
die('Connect Error ('. mysqli_connect_errno() .') '
. mysqli_connect_error());
}
else{
/*
$sql2 = "INSERT INTO $tbl_name2 (Following_Ratings)
VALUES ('".$_POST["Rating"]."')";
*/
$sql1 = "INSERT INTO $tbl_name1 (Reviewer_Name, Comment)
VALUES ('".$_POST["exampleReviewerName"]."','".$_POST["exampleFormControlReview"]."')";
//Check if the query was well executed
//mysqli_query($conn, $sql2);
if (mysqli_query($conn, $sql1) /*mysqli_query($conn, $sql2)*/) {
header('Location: Index.php');
} else {
echo "Error: " . $sql1 . "" . mysqli_error($conn);
}
}
?>