new-bigly-chat/libs/form.php

29 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2024-11-26 21:14:32 -05:00
<?php
2024-11-26 23:37:16 -05:00
function form($title, $form_message, $inputs, $action = '') { ?>
<form class='form' enctype="multipart/form-data" method="POST" action="<?php echo $action ?>">
2024-11-26 21:14:32 -05:00
<h1 class="form-heading">
2024-12-07 07:58:44 -05:00
<?php echo $title ?>
2024-11-26 21:14:32 -05:00
</h1>
<span class='form-message'>
2024-12-07 07:12:42 -05:00
<?php echo htmlspecialchars($form_message) ?>
2024-11-26 21:14:32 -05:00
</span>
<?php
foreach ($inputs as $kv) { ?>
<span class='form-key'>
2024-12-07 07:12:42 -05:00
<?php echo htmlspecialchars($kv['key']) ?>
2024-11-26 21:14:32 -05:00
</span>
<<?php echo (($kv['type'] == 'textarea') ? 'textarea' : 'input') ?>
class='form-input'
2024-12-07 07:12:42 -05:00
type="<?php echo htmlspecialchars($kv['type']) ?>"
name="<?php echo htmlspecialchars($kv['name']) ?>"
2024-12-06 08:26:03 -05:00
<?php echo ($kv['type'] == 'hidden') ? 'hidden' : ''?>
2024-12-07 07:12:42 -05:00
value="<?php echo ($kv['type'] == 'textarea') ? '' : htmlspecialchars($kv['default']) ?>"
><?php echo (($kv['type'] == 'textarea') ? htmlspecialchars($kv['default']) . '</textarea>' : '') ?>
2024-11-26 21:14:32 -05:00
<?php }
?>
<input class='form-button' type="Submit" name="Submit">
</form>
<?php }
2024-12-06 08:26:03 -05:00
?>