cleanup form
This commit is contained in:
parent
73dafb8999
commit
34d322e0c0
3 changed files with 39 additions and 47 deletions
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
require("../libs/page.php");
|
require("../libs/page.php");
|
||||||
|
require("../libs/form.php");
|
||||||
|
|
||||||
function post_handler() {
|
function post_handler() {
|
||||||
global $db;
|
global $db;
|
||||||
|
@ -38,27 +39,10 @@
|
||||||
|
|
||||||
$form_message = post_handler();
|
$form_message = post_handler();
|
||||||
|
|
||||||
// TODO: form builder. this is lazy for testing purposes
|
form("Log in", $form_message, array(
|
||||||
?>
|
array('key' => 'Username', 'type' => 'text', 'name' => 'user', 'default' => ''),
|
||||||
|
array('key' => 'Password', 'type' => 'password', 'name' => 'pass', 'default' => '')
|
||||||
|
));
|
||||||
|
|
||||||
<form class='form' enctype="multipart/form-data" method="POST">
|
|
||||||
<h1 class="form-heading">
|
|
||||||
Join
|
|
||||||
</h1>
|
|
||||||
<span class='form-message'>
|
|
||||||
<?php echo $form_message ?>
|
|
||||||
</span>
|
|
||||||
<span class='form-key'>
|
|
||||||
Username
|
|
||||||
</span>
|
|
||||||
<input class='form-input' type="text" name="user" value="">
|
|
||||||
<span class='form-key'>
|
|
||||||
Password
|
|
||||||
</span>
|
|
||||||
<input class='form-input' type="password" name="pass" value="">
|
|
||||||
<input class='form-button' type="Submit" name="Submit">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
page_footer();
|
page_footer();
|
||||||
?>
|
?>
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
require("../libs/page.php");
|
require("../libs/page.php");
|
||||||
|
require("../libs/form.php");
|
||||||
|
|
||||||
function post_handler() {
|
function post_handler() {
|
||||||
global $db;
|
global $db;
|
||||||
|
@ -46,32 +47,12 @@
|
||||||
page_header();
|
page_header();
|
||||||
|
|
||||||
$form_message = post_handler();
|
$form_message = post_handler();
|
||||||
|
|
||||||
|
form("Join", $form_message, array(
|
||||||
|
array('key' => 'Username', 'type' => 'text', 'name' => 'user', 'default' => ''),
|
||||||
|
array('key' => 'Password', 'type' => 'password', 'name' => 'pass', 'default' => ''),
|
||||||
|
array('key' => 'Password (again)', 'type' => 'password', 'name' => 'pass2', 'default' => '')
|
||||||
|
));
|
||||||
|
|
||||||
// TODO: form builder. this is lazy for testing purposes
|
|
||||||
?>
|
|
||||||
|
|
||||||
<form class='form' enctype="multipart/form-data" method="POST">
|
|
||||||
<h1 class="form-heading">
|
|
||||||
Join
|
|
||||||
</h1>
|
|
||||||
<span class='form-message'>
|
|
||||||
<?php echo $form_message ?>
|
|
||||||
</span>
|
|
||||||
<span class='form-key'>
|
|
||||||
Username
|
|
||||||
</span>
|
|
||||||
<input class='form-input' type="text" name="user" value="">
|
|
||||||
<span class='form-key'>
|
|
||||||
Password
|
|
||||||
</span>
|
|
||||||
<input class='form-input' type="password" name="pass" value="">
|
|
||||||
<span class='form-key'>
|
|
||||||
Password (again)
|
|
||||||
</span>
|
|
||||||
<input class='form-input' type="password" name="pass2" value="">
|
|
||||||
<input class='form-button' type="Submit" name="Submit">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
page_footer();
|
page_footer();
|
||||||
?>
|
?>
|
27
libs/form.php
Normal file
27
libs/form.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
function form($title, $form_message, $inputs) { ?>
|
||||||
|
<form class='form' enctype="multipart/form-data" method="POST">
|
||||||
|
<h1 class="form-heading">
|
||||||
|
<?php echo $title ?>
|
||||||
|
</h1>
|
||||||
|
<span class='form-message'>
|
||||||
|
<?php echo $form_message ?>
|
||||||
|
</span>
|
||||||
|
<?php
|
||||||
|
foreach ($inputs as $kv) { ?>
|
||||||
|
<span class='form-key'>
|
||||||
|
<?php echo $kv['key'] ?>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<<?php echo (($kv['type'] == 'textarea') ? 'textarea' : 'input') ?>
|
||||||
|
class='form-input'
|
||||||
|
type="<?php echo $kv['type'] ?>"
|
||||||
|
name="<?php echo $kv['name'] ?>"
|
||||||
|
value="<?php echo $kv['default'] ?>"
|
||||||
|
>
|
||||||
|
<?php }
|
||||||
|
?>
|
||||||
|
<input class='form-button' type="Submit" name="Submit">
|
||||||
|
</form>
|
||||||
|
<?php }
|
||||||
|
?>
|
Loading…
Reference in a new issue