-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeyrings_setup.php
More file actions
48 lines (43 loc) · 1.45 KB
/
Copy pathkeyrings_setup.php
File metadata and controls
48 lines (43 loc) · 1.45 KB
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
<?php
require_once('inc/global.inc.php');
$smarty->assign("title","Keyring Setup");
if (isset($_GET["id"])) $id = $_GET["id"]; else
if (isset($_POST["id"])) $id = $_POST["id"]; else $id = "";
if (isset($_POST["step"])) $step = $_POST["step"]; else $step = "";
if (isset($_POST["name"])) $name = $_POST["name"]; else $name = "";
$mysql_link=$GLOBALS['mysql_link'];
if($step != '1')
{
if (!empty($id))
{
// We modify an existing reminder
$result = mysqli_query( $mysql_link, "SELECT * FROM `keyrings` where `id`='$id'" )
or die (mysqli_error()."<br>Couldn't execute query: $query");
$row = mysqli_fetch_array( $result );
$name = $row["name"];
}
else
$name = "";
$smarty->assign("id",$id);
$smarty->assign("name",$name);
$smarty->display('keyrings_setup.tpl');
}
else
{
if(empty($id)){
// this is a new keyring
// No error let's add the entry
mysqli_query($mysql_link, "INSERT INTO `keyrings` (`name` ) VALUES('$name')" ) or die(mysqli_error($mysql_link)."<br>Couldn't execute query: $query");
header("Location:keyrings.php");
echo ("keyring Added, redirecting...");
exit ();
} else {
// setting the variable for the update
mysqli_query( $mysql_link, "UPDATE `keyrings` SET `name` = '$name' WHERE `id` = '$id' " );
// Let's go to the Reminder List page
header("Location:keyrings.php");
echo ("keyring Modified, redirecting...");
exit ();
}
}
?>