forked from delongGao/teds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
saveform.php
69 lines (55 loc) · 2.14 KB
/
saveform.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
63
64
65
66
67
68
69
<?php
// ============================== authentication ===============================
//if (session_status() == PHP_SESSION_NONE) {
// session_start();
//}
//session_regenerate_id();
//if(!isset($_SESSION['user_email'])) { // if there is no valid session
// header("Location: index.php?notice=login_first");
//}
require "session_inc.php";
// ============================== authentication ===============================
//debug stuff, setting up values to be taken from previous form
$ids['user'] = 2; //user id - get from session
$ids['persona'] = 0; //persona id - set in form
$ids['scenario'] = 0; //scenario io - set in form
$ids['project'] = $_POST['actProject']; //project id, get from rater.php form submit
$ids['artifact'] = $_POST['actArtifact']; //artifact id, get from rater.php form submit
//set persona id
if($_POST['personae']){
$ids['persona'] = $_POST['personae'];
$_SESSION['personae'] = $_POST['personae'];
}
//set scenario id
if($_POST['scenario']){
$ids['scenario'] = $_POST['scenario'];
$_SESSION['scenario'] = $_POST['scenario'];
}
require_once "dbconnect.php";
try {
$dbq = db_connect();
$dbq->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql['psid'] = 'SELECT psID from personaScenario WHERE personaID='.$ids['persona'].' AND scenarioID='.$ids['scenario'];
// $sql['upid'] = 'SELECT userPersonaeID from userPersonae WHERE userID='.$ids['user'].' AND personaeID='.$ids['persona'];
$sql['upid'] = 'SELECT userPersonaID from userPersona WHERE userID='.$ids['user'].' AND personaID='.$ids['persona'];
$sql['paid'] = 'SELECT projectArtifactID from projectArtifact WHERE projectID='.$ids['project'].' AND artifactID='.$ids['artifact'];
foreach($sql as $k => $v){
foreach ($dbq->query($v) as $row) {
$ids[$k] = $row[0];
}
}
$dbq = NULL;
}
catch(PDOException $e){
// Report errors
printf ($e->getMessage());
}
//store retireved form values into PHP SESSION
$_SESSION['ids'] = $ids;
if($_POST['rate']){
$_SESSION['rateform'] = $_POST['rate'];
}
if($_POST['ratingNarrative'] != ""){
$_SESSION['ratingNarrative'] = $_POST['ratingNarrative'];
}
?>