Form Loader

This feature can save & load form field values.

function save_form ($form_id, $method = 'post')

Save form field values.

$form_id = unique ID.

$method = form method, either GET or POST (default).

function load_form ($form_id)

$form_id = unique ID.

function reset_form ()

Remove saved form. This function automatically called in flush_tpl ().


  • Only one form can be saved each time.
  • This feature relies on ip_config feature.

Example 1 test.php

require './includes/user_init.php';
$cmd = post_param ('cmd');

switch ($cmd)
case 'process':
$name = post_param ('name');
$address = post_param ('address');
$details = post_param ('details');

// save the form before proceed
save_form ('myform');

// all fields must be filled
if (empty ($name) || empty ($address) || empty ($details))
msg_die ('echo', 'Please fill all fields');

// reset the form
// usually called in flush_tpl()
reset_form ();

$output = "Name $name<br />Address $address<br />Details $details";
msg_die ('echo', $output);

// load saved form if available
$row = load_form ('myform');

// if form not saved, initialize the values
if (empty ($row)) $row['name'] = $row['address'] = $row['details'] = '';

$tpl = load_tpl ('test.tpl');
$txt['main_body'] = quick_tpl ($tpl, $row);
flush_tpl ();


<h1>Welcome to test page!</h1>
<form name="myform" action="test.php" method="post">
    <input type="hidden" name="cmd" value="process" />
    <p>Your name: <input type="text" name="name" value="{$name}"/></p>
    <p>Address: <input type="text" name="address" value="{$address}" /></p>
    <p>Details: <textarea name="details">{$details}</textarea></p>
    <p><input type="submit" /></p>


Posted On: Aug-26-2010 @ 07:00am
Last Updated: Jan-01-1970 @ 07:00am

There is no comment. Why not be the first?

More Comments/Post Your Own