Beispiel #1
0
$ex = array("ID", "password");
//providing form language
$lang = array("username" => "Username", "email" => "Email address", "firstname" => "Firstname", "lastname" => "Lastname", "password" => "Password", "repeat_pass" => "Reapeat password", "gender" => "Gender");
$form->set_language($lang);
/*************************
 * Generating form
 *************************/
echo "<fieldset>";
echo "<legend>Register</legend>";
//adding custom password field
$html = "<input type='password' name='password'";
if (isset($_POST["password"])) {
    $html .= " value='" . $_POST["password"] . "'";
}
$html .= "/>";
$form->add_custom_html($html, "password", true);
//adding custom repeated password field
$html = "<input type='password' name='repeat_pass'";
if (isset($_POST["repeat_pass"])) {
    $html .= " value='" . $_POST["repeat_pass"] . "'";
}
$html .= "/>";
$form->add_custom_html($html, "repeat_pass", false);
//adding class predefined validation for password
$form->add_class_validation("password", "char", true);
//adding class predefined validation for repeated password
$form->add_class_validation("repeat_pass", "char", true);
//generating form
$form->insert_form("test_users", $ex);
echo "</fieldset>";
ob_end_flush();
Beispiel #2
0
{
    if ($result === false) {
        echo "<p>No connection</p>";
    } else {
        if ($result === 0) {
            echo "<p>No id generated</p>";
        } else {
            echo "<p>New id is " . $result . "</p>";
        }
    }
}
$form = new auto_form($serverlink);
$form->debug();
//exclude table columns
$ex = array("ID");
//language array
$lang = array("int" => "Integer", "decimal" => "Decimal", "double" => "Float", "text" => "Text", "bool" => "Checkbox", "enum" => "Select", "set" => "Multiple select", "varchar" => "Default");
$form->set_language($lang);
//set on success function
$form->set_onsuccess("success");
//insert form
echo "<fieldset>";
echo "<legend>Insert form</legend>";
$form->insert_form("test_table", $ex);
echo "</fieldset>";
//update form
echo "<fieldset>";
echo "<legend>Update form</legend>";
$form->update_form("test_table", "WHERE ID = '1'", $ex);
echo "</fieldset>";
ob_end_flush();