-
Notifications
You must be signed in to change notification settings - Fork 1
/
script_addParagraphe.php
62 lines (56 loc) · 2.32 KB
/
script_addParagraphe.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
session_start();
require_once "includes/functions.php";
if(isset($_POST['suivant']) || isset($_POST['finir'])){
//Pour scenario
$id = htmlspecialchars($_POST['idSce']);
$text = htmlspecialchars($_POST['textSce']);
$etat = htmlspecialchars($_POST['suiteSce']);
$question = htmlspecialchars($_POST['questSce']);
$idSolution1 = htmlspecialchars($_POST['idSol1']);
$idSolution2 = htmlspecialchars($_POST['idSol2']);
//Pour solution
$solution1 = htmlspecialchars($_POST['sol1']);
$solution2 = htmlspecialchars($_POST['sol2']);
$continuation1 = htmlspecialchars($_POST['nextSce1']);
$continuation2 = htmlspecialchars($_POST['nextSce2']);
if($etat == "continuer"){
//insertion du scénario
$query = getDb()->prepare("insert into `scenario`(story_id, scenario_id, scenario_text, scenario_question, solution1, solution2) values (?,?,?,?,?,?)");
try {
$query->execute(array($_SESSION['idStory'], $id, $text, $question, $idSolution1, $idSolution2));
}
catch(Exception $e){
$e->getMessage();
}
//insertion de la première proposition
$req1 = getDb()->prepare("insert into `solution`(story_id, solution_id, solution_text, continuation) values (?,?,?,?)");
try {
$req1->execute(array($_SESSION['idStory'], $idSolution1, $solution1, $continuation1));
} catch(Exception $e){
$e->getMessage();
}
//insertion de la deuxième proposition
$req2 = getDb()->prepare("insert into `solution`(story_id, solution_id, solution_text, continuation) values (?,?,?,?)");
try {
$req2->execute(array($_SESSION['idStory'], $idSolution2, $solution2, $continuation2));
} catch(Exception $e){
$e->getMessage();
}
}
else {
$query = getDb()->prepare("insert into `scenario`(story_id, scenario_id, scenario_text, scenario_question, solution1, solution2) values (?,?,?,?,?,?)");
try{
$query->execute(array($_SESSION['idStory'], $id, $text, $etat,0,0));
}
catch(Exception $e){
$e->getMessage();
}
}
if(isset($_POST['suivant'])){
header("Location:addParagraphe.php");
}elseif(isset($_POST['finir'])){
header("Location:index.php#slider-container");
}
}
?>