This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathselectpagetoedit.php
68 lines (63 loc) · 2.08 KB
/
selectpagetoedit.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
<?php
require_once ("Includes/simplecms-config.php");
require_once ("Includes/connectDB.php");
include("Includes/header.php");
confirm_is_admin();
if (isset($_POST['submit']))
{
$pageId = $_POST['pageId'];
$query = "SELECT Id FROM pages WHERE id = ?";
$statement = $databaseConnection->prepare($query);
$statement->bind_param('d', $pageId);
$statement->execute();
$statement->store_result();
if ($statement->error)
{
die('Database query failed: ' . $statement->error);
}
// TODO: Check for == 1 instead of > 0 when page names become unique.
$pageExists = $statement->num_rows == 1;
if ($pageExists)
{
header ("Location: editpage.php?id=$pageId");
}
else
{
echo "Failed to locate selected page for edit";
}
}
?>
<div id="main">
<h2>Edit Page</h2>
<form action="selectpagetoedit.php" method="post">
<fieldset>
<legend>Edit Page</legend>
<ol>
<li>
<label for="pageId">Title:</label>
<select id="pageId" name="pageId">
<option value="0">--Select Page--</option>
<?php
$statement = $databaseConnection->prepare("SELECT id, menulabel FROM pages");
$statement->execute();
if($statement->error)
{
die("Database query failed: " . $statement->error);
}
$statement->bind_result($id, $menulabel);
while($statement->fetch())
{
echo "<option value=\"$id\">$menulabel</option>\n";
}
?>
</select>
</li>
</ol>
<input type="submit" name="submit" value="Edit" />
</fieldset>
</form>
<br/>
<a href="index.php">Cancel</a>
</div>
</div> <!-- End of outer-wrapper which opens in header.php -->
<?php include ("Includes/footer.php"); ?>