* * @(#) $Id: test_dependent_validation.php,v 1.1 2007/06/02 08:37:21 mlemos Exp $ * */ require 'forms.php'; $form = new form_class(); $form->NAME = 'dependent_validation_form'; $form->METHOD = 'POST'; $form->ACTION = ''; $form->InvalidCLASS = 'invalid'; $form->ShowAllErrors = 0; $form->debug = 'trigger_error'; $form->AddInput(array('TYPE' => 'checkbox', 'ID' => 'condition', 'NAME' => 'condition', 'CHECKED' => 1, 'LABEL' => '<u>V</u>alidate', 'ACCESSKEY' => 'V')); $form->AddInput(array('TYPE' => 'text', 'ID' => 'dependent', 'NAME' => 'dependent', 'LABEL' => '<u>D</u>ependent', 'ACCESSKEY' => 'D', 'ValidateAsNotEmpty' => 1, 'ValidationErrorMessage' => 'It was not entered a value in the dependent field.', 'DependentValidation' => 'condition')); $form->AddInput(array('TYPE' => 'submit', 'VALUE' => 'Submit', 'NAME' => 'doit')); $form->LoadInputValues($form->WasSubmitted('doit')); $verify = array(); if ($form->WasSubmitted('doit')) { if (($error_message = $form->Validate($verify)) == '') { $doit = 1; } else { $doit = 0; $error_message = HtmlEntities($error_message); } } else { $error_message = ''; $doit = 0; } if (!$doit) { $form->ConnectFormToInput('dependent', 'ONLOAD', 'Focus', array()); }
$form->AddInput(array("TYPE" => "submit", "ID" => "button_subscribe", "NAME" => "user_new_zap", "VALUE" => "Zapisz", "ACCESSKEY" => "u")); $form->AddInput(array("TYPE" => "image", "ID" => "image_subscribe", "NAME" => "grafik_dod_b", "SRC" => "http://www.phpclasses.org/graphics/add.gif", "ALT" => "Submit subscription", "STYLE" => "border-width: 0px;")); $form->AddInput(array("TYPE" => "hidden", "NAME" => "user_track", "VALUE" => "1", "ValidateAsInteger" => 1, "DiscardInvalidValues" => 1)); /* * Add several vertical layout inputs to automatically layout all inputs * in each page without additional HTML templates. */ $form->AddInput(array('ID' => 'personal', 'NAME' => 'personal', 'TYPE' => 'custom', "CustomClass" => "form_layout_vertical_class", 'Inputs' => array('login', 'nazwisko', 'imie', 'haslo', 'gabinety', 'haslo_do', 'akt'), 'Data' => array('separator' => '<tr><td colspan="2"><hr /></td></tr>'), 'InvalidMark' => '[Wpisz]', 'InputFormat' => '<tr><th align="right">{label}:</th><td valign="top">{input} {mark}</td></tr>')); /* * Add a paged layout input to layout the pages of inputs */ $form->AddInput(array('ID' => 'layout', 'NAME' => 'layout', 'TYPE' => 'custom', 'CustomClass' => 'form_layout_paged_class', 'Pages' => array('personal' => array('Name' => 'Dodanie użytkownika')), 'AutoAdjustSize' => 0, 'FadePagesTime' => 0.25)); /* * Load form input values eventually from the submitted form. */ $form->LoadInputValues($form->WasSubmitted()); /* * Empty the array that will list the values with invalid field after * validation. */ $verify = array(); /* * Check if the global array variable corresponding to hidden input field * is defined, meaning that the form was submitted as opposed to being * displayed for the first time. */ if ($form->WasSubmitted()) { /* * Therefore we need to validate the submitted form values. */ if (($error_message = $form->Validate($verify)) == "") {
* test_encoded_pasword.php * * @(#) $Header: /home/mlemos/cvsroot/forms/test_encoded_password.php,v 1.6 2006/12/20 06:21:16 mlemos Exp $ * */ require "forms.php"; $form = new form_class(); $form->NAME = "login_form"; $form->METHOD = "GET"; $form->ACTION = ""; $form->debug = "trigger_error"; $form->AddInput(array("TYPE" => "text", "NAME" => "access_name", "MAXLENGTH" => 20, "Capitalization" => "uppercase", "ValidateRegularExpression" => "^[a-zA-Z0-9\\-_]+\$", "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid access name")); $form->AddInput(array("TYPE" => "hidden", "NAME" => "user_login", "ID" => "user_login", "VALUE" => "")); $form->AddInput(array("TYPE" => "password", "NAME" => "password", "ONCHANGE" => "if(value.toLowerCase) value=value.toLowerCase()", "Encoding" => "MD5", "EncodingFunctionVerification" => "loaded_MD5", "EncodedField" => "user_login", "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid password")); $form->AddInput(array("TYPE" => "submit", "VALUE" => "Login", "NAME" => "doit")); $form->LoadInputValues($form->WasSubmitted("doit")); $verify = array(); if ($form->WasSubmitted("doit")) { $user_login = $form->GetInputValue("user_login"); if (strcmp($user_login, "")) { $password = $user_login; $user_login = ""; $form->SetInputValue("user_login", $user_login); } else { $password = $form->GetInputValue("password"); if (strcmp($password, "")) { $password = md5(strtolower($password)); } } $form->SetInputValue("password", $password); if (($error_message = $form->Validate($verify)) == "") {
* */ require 'forms.php'; require 'form_secure_submit.php'; $key = "my secret key"; $form = new form_class(); $form->ID = 'secure_form'; $form->METHOD = 'POST'; $form->ACTION = '?'; $form->debug = 'trigger_error'; $error = $form->AddInput(array('TYPE' => 'custom', 'VALUE' => 'Secure submit', 'ID' => 'secure_submit', 'NAME' => 'secure_submit', 'CustomClass' => 'form_secure_submit_class', 'Key' => $key)); if (strlen($error)) { die("Error: " . $error); } $submitted = $form->WasSubmitted('secure_submit'); $form->LoadInputValues($submitted); $verify = array(); if ($submitted) { if (strlen($error_message = $form->Validate($verify)) == 0) { $doit = 1; } else { $doit = 0; $error_message = HtmlEntities($error_message); } } else { $error_message = ''; $doit = 0; } if (!$doit) { $focus = 'secure_submit'; $form->ConnectFormToInput($focus, 'ONLOAD', 'Focus', array());