-
Notifications
You must be signed in to change notification settings - Fork 0
/
twoOfAPair.php
39 lines (31 loc) · 1.12 KB
/
twoOfAPair.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
//error reporting
ini_set('display_errors', 'On');
$mysqli = new mysqli('oniddb.cws.oregonstate.edu', 'palmerja-db', '0pw9EnF5GTR6Mu6U', 'palmerja-db');
if($mysqli->connect_errno){
echo "Connection error " . $mysqli->connect_errno . " " . $mysqli->connect_error;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="projectOutline.css" />
</head>
<?php
if(!($stmt = $mysqli->prepare("INSERT INTO pair (food_id, wine_id)
VALUES ((SELECT id FROM food WHERE name = ?), (SELECT id FROM wine WHERE name = ?))"))){
echo "Prepare failed: " . $stmt->errno . " " . $stmt->error;
}
if(!($stmt->bind_param("ss",$_POST['food_name'],$_POST['wine_name']))){
echo "Bind failed: " . $stmt->errno . " " . $stmt->error;
}
if(!$stmt->execute()){
echo "Execute failed: " . $stmt->errno . " " . $stmt->error;
} else {
echo "You added " . $stmt->affected_rows . " row to our pair list, thank you!";
}
?>
<div class="button"><a href="main.php">Return To Main Page</a></div>
</html>