sync
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
include_once('includes/functions.php');
|
||||
|
||||
/*
|
||||
* Creates a form from an associative array of fields.
|
||||
*
|
||||
* See includes/input_validation.php for the structure of a fields array.
|
||||
*/
|
||||
function generate_form($fields, $error)
|
||||
{
|
||||
$form = '
|
||||
<div class="standard_box outer_shadow form_container">
|
||||
<form method="' . $fields['method'] . '" action="' . $fields['action'] . '">
|
||||
';
|
||||
|
||||
foreach ($fields as $field => $metadata) {
|
||||
if ($field == 'method' || $field == 'action')
|
||||
continue;
|
||||
|
||||
$form .= '
|
||||
<div class="input_box inner_shadow">
|
||||
<label for="' . $field . '">' . ucwords($metadata['label']) . '</label>
|
||||
<input id="' . $field . '" name="' . $field . '" type="' . $metadata['type'] . '" placeholder="' . $metadata['placeholder'] . '">
|
||||
</div>
|
||||
';
|
||||
}
|
||||
|
||||
$form .= '
|
||||
<input type="submit" class="submit_button">
|
||||
</form>
|
||||
';
|
||||
|
||||
if (!empty($error)) {
|
||||
$form .= '
|
||||
<div class="standard_box inner_shadow error">
|
||||
<p class="error">' . ucwords($error) . ' information!</p>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
|
||||
$form .= '
|
||||
</div>
|
||||
';
|
||||
|
||||
return $form;
|
||||
}
|
||||
Reference in New Issue
Block a user