Make use of Yapter Template Engine

This commit is contained in:
2023-02-13 09:31:40 +01:00
parent 7322231d3e
commit 8d00ee5e1b
100 changed files with 4804 additions and 2666 deletions

View File

@@ -1,62 +1,24 @@
<?php
include("header.php");
// display only if admin
if($_SESSION['suser_level'] >= 2) {
// set template
$tp = new Template("tpl/locationadd.tpl");
// check for submit
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
$location_name = $_POST['location_name'];
$parent = $_POST['parent'];
mysql_query("INSERT INTO location (location_name, parent) VALUE ('$location_name', '$parent')") or die(mysql_error());
$location_id = mysql_insert_id();
header_location("locationview.php?location_id=" . $location_id);
}
?>
// set language variables
$tp->setvars($lang);
<form method="POST" action="locationadd.php">
<table border="0">
<tr>
<td colspan="2">
<b>Add new location:</b><br>
</td>
</tr>
<tr>
<td>
Location name:
</td>
<td>
<input type="text" name="location_name">
</td>
</tr>
<tr>
<td>
Parent:
</td>
<td>
<select name="parent">
<option value="0">(none)</option>
<?php
$result = mysql_query("SELECT location_name, location_id FROM location ORDER BY location_name");
while ($row = mysql_fetch_object($result)) {
echo '<option value="' . $row->location_id . '">' . $row->location_name . '</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit"><input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
// end display only if admin
// get location info
$result = mysql_query("SELECT location_id, location_name FROM location ORDER BY location_name");
for ($i=0;$row=mysql_fetch_object($result);$i++) {
$tp->set("location_id", $row->location_id);
$tp->set("location_name", $row->location_name);
$tp->parse("locationrow");
}
if (($i>0) ? $tp->parse("location") : $tp->hide("location"));
// output
$tp->parse();
$tp->spit();
include("footer.php");
?>