-
Notifications
You must be signed in to change notification settings - Fork 1
/
addSeminar.php
24 lines (20 loc) · 1023 Bytes
/
addSeminar.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
<?php
$speaker = $_REQUEST['speaker'];
$date = $_REQUEST['date'];
$location = $_REQUEST['location'];
$description = $_REQUEST['description'];
$food = $_REQUEST['food'];
$department = $_REQUEST['department'];
$time = $_REQUEST['time'];
$db = new PDO('mysql:host=localhost;dbname=project2', 'root', 'password'); //get db connection
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("INSERT INTO seminars(date, time, speaker, description, department, food, location) VALUES(STR_TO_DATE(:date, '%m/%d/%Y'),:time,:speaker,:description,:department,:food,:location)"); //prepare insert
$data = array(':date' => $date, ':time' => $time, ':speaker' => $speaker, ':description' => $description, ':department' => $department, ':food'=>$food, ':location'=>$location); //array containing data
try {
$stmt->execute($data);
}
catch (PDOException $e) {
echo $e->getMessage();
}
header( 'Location: http://ec2-54-205-135-226.compute-1.amazonaws.com/index.php' ) ; //send user back to main page
?>