rendered paste body<?php
if ( isset($_POST['add']) ):
$surname = (string) $_POST['surname'];
$name = (string) $_POST['lastname'];
$agent = (string) $_POST['agent_id'];
$house = (string) $_POST['house_id'];
?>
<?php else: ?>
<form action="<?php print($_SERVER['PHP_SELF']); ?>?add=children" method="post">
<input type="hidden" name="add" value="true" />
<label>Förnamn</label>
<input type="text" name="surname" />
<br /><br />
<label>Efternamn</label>
<input type="text" name="lastname" />
<br /><br />
<?php /* Följande kommer användas till att lägga till ett nytt hus (om nödvändigt) */ ?>
<label>Ort</label>
<input type="text" name="ort" />
<br /><br />
<label>Gata</label>
<input type="text" name="street" />
<br /><br />
<label>Husnummer</label>
<input type="text" name="number" />
<br /><br />
<label>Postnummer</label>
<input type="text" name="zip" />
<br /><br />
<label>Land</label>
<select name="country">
<?php
$countries = $DB -> Query("SELECT code, name FROM country;");
foreach( $countries as $country ) {
print('<option value="' . $country['code'] . '">' . $country['name'] . '</option>');
}
?>
</select>
<br /><br />
<label>Ansvarig nisse</label>
<select name="agent">
<?php
$helpers = $DB -> Query("SELECT id FROM agent");
foreach( $helpers as $helper) {
$id = $helper['id'];
$details = $DB -> Query("SELECT surname, lastname FROM helper WHERE id = {$id};");
$surname = $details[0]['surname'];
$lastname = $details[0]['lastname'];
print('<option value="' . $id . '">' . $surname . ' ' . $lastname . '</option>');
}
?>
</select>
<br /><br />
<input type="submit" value="Lägg till" />
</form>
<?php endif; ?>