-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave.php
More file actions
33 lines (28 loc) · 843 Bytes
/
save.php
File metadata and controls
33 lines (28 loc) · 843 Bytes
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
<?php
session_start();
include("dbconnect.php");
function check_logged(){
global $_SESSION;
if (!isset($_SESSION['logged'])) { //if not logged in, then direct to login
header("Location: login.php");
} else { //logged in, so go ahead and save
include("savemeal.php");
}
};
if (isset($_POST['save'])) { //if user opted to save, check for login then save
$public = FALSE;
$title = $_POST['title'];
$rating = $_POST['rating'];
$comments = $_POST['comments'];
$meals = array();
foreach ($_SESSION['dishes'] as $key) {
echo $meals[] = $key;
}
$_SESSION['tosave'] = array($public, $title, $meals, $rating, $comments);
check_logged();
} else { //if user opted to skip, send to index
unset($_SESSION['dishes']);
header( 'Location: index.php' ) ;
}
mysql_close($dbhandle);
?>