-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprocess.php
34 lines (28 loc) · 1.15 KB
/
process.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
<?php
require "database_connect.php";
$db = new PDO($dsn, $username, $password);
$title = $_POST['title'];
$type = intval($_GET['type']);
$user=$_POST['user'];
$year= $_GET['year'];
if($type==0){
$insertStory= $db->prepare("INSERT INTO stories (title, year, user, type) VALUES (:title, :year, :user,:type)");
$insertStory->bindValue("title",$title, PDO::PARAM_STR);
$insertStory->bindValue("year",$year, PDO::PARAM_STR);
$insertStory->bindValue("user",$user, PDO::PARAM_STR);
$insertStory->bindValue("type",$type, PDO::PARAM_STR);
$insertStory->execute();
} elseif($type==1){
$story = htmlentities($_POST['story']);
$insertStory= $db->prepare("INSERT INTO stories (title, year, user, type, story) VALUES (:title, :year, :user,:type,:story)");
$insertStory->bindValue("title",$title, PDO::PARAM_STR);
$insertStory->bindValue("year",$year, PDO::PARAM_STR);
$insertStory->bindValue("user",$user, PDO::PARAM_STR);
$insertStory->bindValue("type",$type, PDO::PARAM_STR);
$insertStory->bindValue("story",$story, PDO::PARAM_STR);
$insertStory->execute();
}else{
echo "Error.";
}
header( 'Location: history.php?year='.$year ) ;
?>