require "./ajax/forms.php"; require "./ajax/form_layout_vertical.php"; require "./ajax/form_layout_paged.php"; require "./ajax/form_animation.php"; $form = new form_class(); $form->encoding = "utf-8"; $form->NAME = "subscription_form"; $form->METHOD = "POST"; $form->ACTION = ""; $form->debug = "trigger_error"; $form->ResubmitConfirmMessage = 'xx'; $form->OutputPasswordValues = 1; $form->OptionsSeparator = "<br>\n"; $form->ShowAllErrors = 1; $form->InvalidCLASS = 'butt4'; $form->AddInput(array("TYPE" => "text", "NAME" => "login", "ID" => "login", "MAXLENGTH" => 30, "SIZE" => 21, "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "Brak nazwy użytkownika", "LABEL" => "Nazwa użytkownika", "ACCESSKEY" => "I")); $form->AddInput(array("TYPE" => "text", "NAME" => "nazwisko", "ID" => "nazwisko", "MAXLENGTH" => 30, "SIZE" => 21, "Capitalization" => "uppercase", "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "Brak nazwiska", "LABEL" => "Nazwisko", "ACCESSKEY" => "I")); $form->AddInput(array("TYPE" => "text", "NAME" => "imie", "ID" => "imie", "MAXLENGTH" => 25, "SIZE" => 16, "Capitalization" => "uppercase", "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "Brak imienia", "LABEL" => "Imię", "ACCESSKEY" => "I")); $form->AddInput(array("TYPE" => "password", "NAME" => "haslo", "ID" => "haslo", "MAXLENGTH" => 15, "SIZE" => 16, "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "Brak hasła", "LABEL" => "Hasło", "ACCESSKEY" => "I")); $form->AddInput(array("TYPE" => "select", "NAME" => "gabinety", "ID" => "gabinety", "VALUE" => "2", "SIZE" => 8, "OPTIONS" => $sl_gab, "ValidationErrorMessage" => "Brak wybranego gabinetu", "LABEL" => "Gabinet")); $form->AddInput(array("TYPE" => "text", "NAME" => "haslo_do", "ID" => "haslo_do", "MAXLENGTH" => 10, "SIZE" => 11, "Capitalization" => "uppercase", "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "Brak daty ważności hasła", "LABEL" => "Ważnośc hasła", "ACCESSKEY" => "I", "VALUE" => date("Y-m-d", strtotime("+30 days")))); $form->AddInput(array("TYPE" => "checkbox", "NAME" => "akt", "ID" => "akt", "LABEL" => "Aktywny", "ACCESSKEY" => "I", "CHECKED" => 1)); $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>')); /*
* Output multiple select options values separated by line breaks */ $form->OptionsSeparator = "<br>\n"; /* * Output all validation errors at once. */ $form->ShowAllErrors = 1; /* * CSS class to apply to all invalid inputs. * Set to a non-empty string to specify the invalid input CSS class */ $form->InvalidCLASS = 'invalid'; /* * Define the form field properties even if they may not be displayed. */ $form->AddInput(array("TYPE" => "text", "NAME" => "email", "ID" => "email", "MAXLENGTH" => 100, "Capitalization" => "lowercase", "ValidateAsEmail" => 1, "ValidationErrorMessage" => "It was not specified a valid e-mail address", "LABEL" => "<u>E</u>-mail address", "ACCESSKEY" => "E")); $form->AddInput(array("TYPE" => "select", "NAME" => "credit_card_type", "ID" => "credit_card_type", "VALUE" => "unknown", "SIZE" => 2, "OPTIONS" => array("unknown" => "Unknown", "mastercard" => "Master Card", "visa" => "Visa", "amex" => "American Express", "dinersclub" => "Diners Club", "carteblanche" => "Carte Blanche", "discover" => "Discover", "enroute" => "enRoute", "jcb" => "JCB"), "ValidationErrorMessage" => "It was not specified a valid credit card type", "LABEL" => "Credit card t<u>y</u>pe", "ACCESSKEY" => "y")); $form->AddInput(array("TYPE" => "text", "NAME" => "credit_card_number", "ID" => "credit_card_number", "SIZE" => 20, "ValidateOptionalValue" => "", "ValidateAsCreditCard" => "field", "ValidationCreditCardTypeField" => "credit_card_type", "ValidationErrorMessage" => "It wasn't specified a valid credit card number", "LABEL" => "Credit card <u>n</u>umber", "ACCESSKEY" => "n")); $form->AddInput(array("TYPE" => "text", "NAME" => "user_name", "ID" => "user_name", "MAXLENGTH" => 60, "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid name", "LABEL" => "<u>P</u>ersonal name", "ACCESSKEY" => "P")); $form->AddInput(array("TYPE" => "text", "NAME" => "age", "ID" => "age", "ValidateAsInteger" => 1, "ValidationLowerLimit" => 18, "ValidationUpperLimit" => 65, "ValidationErrorMessage" => "Nie poprawny wiek", "LABEL" => "<u>W</u>iek", "ACCESSKEY" => "w")); $form->AddInput(array("TYPE" => "text", "NAME" => "weight", "ID" => "weight", "ValidateAsFloat" => 1, "ValidationLowerLimit" => 10, "ValidationErrorMessage" => "It was not specified a valid weight", "LABEL" => "<u>W</u>eight", "ACCESSKEY" => "W")); $form->AddInput(array("TYPE" => "text", "NAME" => "home_page", "ID" => "home_page", "ReplacePatterns" => array("^\\s+" => "", "\\s+\$" => "", "^([wW]{3}\\.)" => "http://\\1", "^([^:]+)\$" => "http://\\1", "^(http|https)://(([-!#\$%&'*+.0-9=?A-Z^_`a-z{|}~]+\\.)+[A-Za-z]{2,6}(:[0-9]+)?)\$" => "\\1://\\2/"), "ValidateRegularExpression" => '^(http|https)\\://(([-!#\\$%&\'*+.0-9=?A-Z^_`a-z{|}~]+\\.)+[A-Za-z]{2,6})(\\:[0-9]+)?(/)?/', "ValidationErrorMessage" => "It was not specified a valid home page URL", "LABEL" => "H<u>o</u>me page", "ACCESSKEY" => "o")); $form->AddInput(array("TYPE" => "text", "NAME" => "alias", "ID" => "alias", "MAXLENGTH" => 20, "Capitalization" => "uppercase", "ValidateRegularExpression" => "^[a-zA-Z0-9]+\$", "ValidateRegularExpressionErrorMessage" => "The alias may only contain letters and digits", "ValidateAsNotEmpty" => 1, "ValidateAsNotEmptyErrorMessage" => "It was not specified the alias", "ValidateMinimumLength" => 5, "ValidateMinimumLengthErrorMessage" => "It was not specified an alias shorter than 5 characters", "LABEL" => "Acce<u>s</u>s name", "ACCESSKEY" => "s")); $form->AddInput(array("TYPE" => "password", "NAME" => "password", "ID" => "password", "ONCHANGE" => "if(value.toLowerCase) value=value.toLowerCase()", "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid password", "LABEL" => "Passwor<u>d</u>", "ACCESSKEY" => "d", "ReadOnlyMark" => "********")); $form->AddInput(array("TYPE" => "password", "NAME" => "confirm_password", "ID" => "confirm_password", "ONCHANGE" => "if(value.toLowerCase) value=value.toLowerCase()", "ValidateAsEqualTo" => "password", "ValidationErrorMessage" => "The password is not equal to the confirmation", "LABEL" => "<u>C</u>onfirm password", "ACCESSKEY" => "C", "ReadOnlyMark" => "********")); $form->AddInput(array("TYPE" => "text", "NAME" => "reminder", "ID" => "reminder", "ValidateAsNotEmpty" => 1, "ValidateAsNotEmptyErrorMessage" => "It was not specified a reminder phrase", "ValidateAsDifferentFrom" => "password", "ValidateAsDifferentFromErrorMessage" => "The reminder phrase may not be equal to the password", "LABEL" => "Password <u>r</u>eminder", "ACCESSKEY" => "r")); $form->AddInput(array("TYPE" => "select", "MULTIPLE" => 1, "NAME" => "interests", "ID" => "interests", "SELECTED" => array("other"), "SIZE" => 4, "OPTIONS" => array("arts" => "Arts", "business" => "Business", "computers" => "Computers", "education" => "Education", "entertainment" => "Entertainment", "health" => "Health", "news" => "News", "politics" => "Politics", "sports" => "Sports", "science" => "Science", "other" => "Other"), "ValidateAsSet" => 1, "ValidationErrorMessage" => "It were not specified any interests.", "LABEL" => "<u>I</u>nterests", "ACCESSKEY" => "I")); $form->AddInput(array("TYPE" => "checkbox", "NAME" => "notification", "ID" => "email_notification", "VALUE" => "email", "CHECKED" => 0, "MULTIPLE" => 1, "ValidateAsSet" => 1, "ValidateAsSetErrorMessage" => "It were not specified any types of notification", "LABEL" => "E-<u>m</u>ail", "ACCESSKEY" => "m", "ReadOnlyMark" => "[X]")); $form->AddInput(array("TYPE" => "checkbox", "NAME" => "notification", "ID" => "phone_notification", "VALUE" => "phone", "CHECKED" => 0, "MULTIPLE" => 1, "LABEL" => "P<u>h</u>one", "ACCESSKEY" => "h", "ReadOnlyMark" => "[X]")); $form->AddInput(array("TYPE" => "radio", "NAME" => "subscription_type", "VALUE" => "administrator", "ID" => "administrator_subscription", "ValidateAsSet" => 1, "ValidateAsSetErrorMessage" => "It was not specified the subscription type", "LABEL" => "Adm<u>i</u>nistrator", "ACCESSKEY" => "i", "ReadOnlyMark" => "[X]")); $form->AddInput(array("TYPE" => "radio", "NAME" => "subscription_type", "VALUE" => "user", "ID" => "user_subscription", "LABEL" => "<u>U</u>ser", "ACCESSKEY" => "U", "ReadOnlyMark" => "[X]"));
/* * test_upload.php * * @(#) $Header: /home/mlemos/cvsroot/forms/test_upload.php,v 1.8 2007/07/02 03:07:56 mlemos Exp $ * */ require "forms.php"; $form = new form_class(); $form->NAME = "subscription_form"; $form->METHOD = "POST"; $form->ACTION = ""; $form->ENCTYPE = "multipart/form-data"; $form->debug = "trigger_error"; $form->ResubmitConfirmMessage = "Are you sure you want to submit this form again?"; $form->AddInput(array("TYPE" => "file", "NAME" => "userfile", "ACCEPT" => "image/gif", "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid file to upload")); $form->AddInput(array("TYPE" => "submit", "VALUE" => "Upload", "NAME" => "doit")); $form->AddInput(array("TYPE" => "hidden", "NAME" => "MAX_FILE_SIZE", "VALUE" => 1000000)); $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; }
/* * test_list_select.php * * @(#) $Header: /home/mlemos/cvsroot/forms/test_list_select.php,v 1.1 2009/11/11 08:19:27 mlemos Exp $ * */ require "forms.php"; require "form_list_select.php"; $currencies = array('' => 'None', 'USD' => 'USD', 'EUR' => 'EUR', 'GPB' => 'GBP', 'YEN' => 'YEN'); $form = new form_class(); $form->NAME = "currency_form"; $form->METHOD = "POST"; $form->ACTION = ""; $form->debug = "error_log"; $form->AddInput(array("TYPE" => "custom", "ID" => "currency", "NAME" => "currency", "LABEL" => "<u>C</u>urrency", "ACCESSKEY" => "t", "CustomClass" => "form_list_select_class", "VALUE" => "", "OPTIONS" => $currencies, 'Columns' => array(array('Type' => 'Input'), array('Type' => 'Option', 'Header' => 'Symbol'), array('Type' => 'Data', 'Header' => 'Name', 'Row' => 'Name'), array('Type' => 'Data', 'Header' => 'Region', 'Row' => 'Region'), array('Type' => 'Data', 'Header' => 'Value', 'Row' => 'Value')), 'Rows' => array('USD' => array('Name' => 'Dollar', 'Region' => 'United States', 'Value' => '<tt>$1.00</tt>'), 'EUR' => array('Name' => 'Euro', 'Region' => 'Europe', 'Value' => '<tt>$1.4986</tt>'), 'GPB' => array('Name' => 'Pound', 'Region' => 'United Kingdom', 'Value' => '<tt>$1.6737</tt>'), 'YEN' => array('Name' => 'Yen', 'Region' => 'Japan', 'Value' => '<tt>$0.011132</tt>')))); $form->AddInput(array("TYPE" => "submit", "VALUE" => "Choose", "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) {
/* * test_secure_submit.php * * @(#) $Header: /home/mlemos/cvsroot/forms/test_secure_submit.php,v 1.2 2007/05/09 01:43:29 mlemos Exp $ * */ 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 = '';
$form->METHOD = "POST"; $form->ACTION = ""; $form->debug = "trigger_error"; /* * This is just for testing purposes */ if (defined('GOOGLE_MAPS_KEY')) { $key = GOOGLE_MAPS_KEY; } if (defined('ADSENSE_PUBLISHER')) { $adsense_publisher = ADSENSE_PUBLISHER; } if (defined('ADSENSE_CHANNEL')) { $adsense_publisher = ADSENSE_CHANNEL; } $error = $form->AddInput(array("TYPE" => "custom", "CustomClass" => "form_map_location_class", "ID" => "map", "LABEL" => "<u>P</u>oint your location on the map:", "ACCESSKEY" => "P", "STYLE" => "width: 600px; height: 400px", "Key" => $key, "Latitude" => 37.4419, "Longitude" => -122.1419, "ZoomLevel" => 3, "ZoomMarkers" => 1, "BoundsOffset" => 1.0, "MapType" => "Hybrid", "LatitudeLabel" => "<b>Latitude:</b>", "LatitudeStyle" => "background-color: #f1d9d9;", "LongitudeLabel" => "<b>Longitude:</b>", "LongitudeStyle" => "background-color: #f1d9d9", "Controls" => array("LargeMap" => array(), "Scale" => array(), "MapType" => array()), 'AdsManager' => array('Publisher' => $adsense_publisher, 'MaxAdsOnMap' => 1, 'Style' => 'adunit', 'Channel' => $adsense_channel), "Markers" => array(array("Latitude" => 37.78156937014928, "Longitude" => -122.42340087890625, "Information" => "San Francisco", "Link" => "http://www.ci.sf.ca.us/", "Target" => "_blank", "Title" => "Click here to go to the official San Francisco government site on a new window"), array("Latitude" => 38.58252615935333, "Longitude" => -121.48818969726562, "Information" => "Sacramento"), array("Latitude" => 34.05265942137599, "Longitude" => -118.2403564453125, "Information" => "Los Angeles", "Link" => "http://www.ci.la.ca.us/", "Title" => "Click here to go to the official Los Angeles government site on this window"), array("Latitude" => 32.71855479966606, "Longitude" => -117.16232299804688, "Information" => "San Diego")))); if (strlen($error)) { die("Error: " . $error); } $form->AddInput(array("TYPE" => "submit", "VALUE" => "Submit", "NAME" => "doit")); $form->AddInput(array("TYPE" => "textarea", "ID" => "address", "NAME" => "address", "COLS" => 60, "ROWS" => 3, "LABEL" => "<u>A</u>ddress:", "ACCESSKEY" => "A", "VALUE" => "")); $form->AddInput(array("TYPE" => "select", "ID" => "country", "NAME" => "country", "VALUE" => "", "OPTIONS" => $country_codes, "LABEL" => "<u>C</u>ountry:", "ACCESSKEY" => "C")); $form->AddInput(array("TYPE" => "button", "ID" => "locate_address", "NAME" => "locate_address", "VALUE" => "Locate address")); $form->Connect("locate_address", "map", "ONCLICK", "LocateAddress", array("Address" => "address", "Country" => "country", "CountryValue" => "SelectedOption")); $form->AddInput(array("TYPE" => "submit", "ID" => "refresh", "VALUE" => "Refresh", "SubForm" => "refresh")); $form->LoadInputValues($form->WasSubmitted("doit")); $verify = array(); if ($form->WasSubmitted("doit")) { if (($error_message = $form->Validate($verify)) == "") { $doit = 1; } else {
<?php /* * 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)); }
require 'forms.php'; require 'form_linked_select.php'; require 'form_mdb2_linked_select.php'; $dsn = array("phptype" => "mysql", "username" => "mysqluser", "password" => "mysqlpassword", "database" => "locations", "Debug" => "error_log"); $database =& MDB2::connect($dsn); if (PEAR::isError($database)) { var_dump($database->getMessage()); die; } $continents = array("" => "Select continent", "na" => "North America", "eu" => "Europe", "sa" => "South America", "as" => "Asia", "oc" => "Oceania"); $form = new form_class(); $form->NAME = "location_form"; $form->METHOD = "GET"; $form->ACTION = ""; $form->debug = "OutputDebug"; $form->AddInput(array("TYPE" => "select", "ID" => "continent", "NAME" => "continent", "LABEL" => "<u>C</u>ontinent", "ACCESSKEY" => "C", "VALUE" => "", "OPTIONS" => $continents, "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid continent.")); $form->AddInput(array("TYPE" => "custom", "ID" => "country", "NAME" => "country", "LABEL" => "Coun<u>t</u>ry", "ACCESSKEY" => "t", "CustomClass" => "form_mdb2_linked_select_class", "Connection" => &$database, "OptionsQuery" => "SELECT code, name FROM countries WHERE continent=?", "DefaultOption" => "", "DefaultOptionValue" => "Select country", "Dynamic" => 1, "VALUE" => "", "LinkedInput" => "continent", "SIZE" => 3, "AutoWidthLimit" => 0, "AutoHeightLimit" => 0, "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid country.")); $form->AddInput(array("TYPE" => "custom", "ID" => "location", "NAME" => "location", "LABEL" => "<u>L</u>ocation", "ACCESSKEY" => "L", "CustomClass" => "form_mdb2_linked_select_class", "Connection" => &$database, "OptionsQuery" => "SELECT code, name FROM locations WHERE country=?", "DefaultOption" => "", "DefaultOptionValue" => "Select location", "Dynamic" => 1, "VALUE" => "", "LinkedInput" => "country", "SIZE" => 3, "AutoWidthLimit" => 0, "AutoHeightLimit" => 0, "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid location.")); $form->AddInput(array("TYPE" => "submit", "VALUE" => ">", "NAME" => "update", "SubForm" => "update")); $form->AddInput(array("TYPE" => "submit", "VALUE" => "Go", "NAME" => "doit")); $form->Connect("location", "doit", "ONCHANGE", "Click", array()); /* * This code is necessary to handle the requests for serving the * dynamically generated lists of options for linked select inputs. */ $form->HandleEvent($processed); if ($processed) { exit; } $form->LoadInputValues($form->WasSubmitted("doit")); $verify = array();
* */ /* * Include form class code. */ require "forms.php"; require "form_ajax_submit.php"; /* * Create a form object. */ $form = new form_class(); $form->NAME = "subscription_form"; $form->METHOD = "POST"; $form->ACTION = ""; $form->debug = "error_log"; $form->AddInput(array("TYPE" => "text", "NAME" => "description", "ID" => "description", "LABEL" => "<u>D</u>escription", "ACCESSKEY" => "D", "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid description.")); $form->AddInput(array("TYPE" => "file", "NAME" => "file", "ID" => "file", "LABEL" => "<u>F</u>ile", "ACCESSKEY" => "F", "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid file.")); $form->AddInput(array("TYPE" => "submit", "NAME" => "doit", "ID" => "doit", "VALUE" => "Submit")); $form->AddInput(array("TYPE" => "custom", "NAME" => "sender", "ID" => "sender", "CustomClass" => "form_ajax_submit_class", "FeedbackElement" => "feedback", "SubmitFeedback" => '<img src="indicator.gif" width="16" height="16" /> Submitting form ...', "TimeoutFeedback" => 'The communication with the server has timed out.', "Timeout" => 60, "ONTIMEOUT" => "", "DebugConsole" => "debug_console")); /* * Connect the doit submit button to the sender AJAX submit input */ $form->Connect("doit", "sender", "ONCLICK", "Submit", array()); /* * Handle client side events on the server side. * Do not output anything before these lines. */ $form->HandleEvent($processed); if ($processed) { exit; }
* Output multiple select options values separated by line breaks */ $form->OptionsSeparator = "<br>\n"; /* * Output all validation errors at once. */ $form->ShowAllErrors = 1; /* * CSS class to apply to all invalid inputs. * Set to a non-empty string to specify the invalid input CSS class */ $form->InvalidCLASS = 'invalid'; /* * Define the form field properties even if they may not be displayed. */ $form->AddInput(array("TYPE" => "text", "NAME" => "email", "ID" => "email", "MAXLENGTH" => 100, "Capitalization" => "lowercase", "ValidateAsEmail" => 1, "ValidationErrorMessage" => "It was not specified a valid e-mail address.", "LABEL" => "<u>E</u>-mail address", "ACCESSKEY" => "E")); $form->AddInput(array("TYPE" => "select", "NAME" => "credit_card_type", "ID" => "credit_card_type", "VALUE" => "unknown", "SIZE" => 2, "OPTIONS" => array("unknown" => "Unknown", "mastercard" => "Master Card", "visa" => "Visa", "amex" => "American Express", "dinersclub" => "Diners Club", "carteblanche" => "Carte Blanche", "discover" => "Discover", "enroute" => "enRoute", "jcb" => "JCB"), "ValidationErrorMessage" => "It was not specified a valid credit card type.", "LABEL" => "Credit card t<u>y</u>pe", "ACCESSKEY" => "y")); $form->AddInput(array("TYPE" => "text", "NAME" => "credit_card_number", "ID" => "credit_card_number", "SIZE" => 20, "ValidateOptionalValue" => "", "ValidateAsCreditCard" => "field", "ValidationCreditCardTypeField" => "credit_card_type", "ValidationErrorMessage" => "It wasn't specified a valid credit card number.", "LABEL" => "Credit card <u>n</u>umber", "ACCESSKEY" => "n")); $form->AddInput(array("TYPE" => "text", "NAME" => "user_name", "ID" => "user_name", "MAXLENGTH" => 60, "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid name.", "LABEL" => "<u>P</u>ersonal name", "ACCESSKEY" => "P")); $form->AddInput(array("TYPE" => "text", "NAME" => "age", "ID" => "age", "ValidateAsInteger" => 1, "ValidationLowerLimit" => 18, "ValidationUpperLimit" => 65, "ValidationErrorMessage" => "It was not specified a valid age.", "LABEL" => "<u>A</u>ge", "ACCESSKEY" => "A")); $form->AddInput(array("TYPE" => "text", "NAME" => "weight", "ID" => "weight", "ValidateAsFloat" => 1, "ValidationLowerLimit" => 10, "ValidationErrorMessage" => "It was not specified a valid weight.", "LABEL" => "<u>W</u>eight", "ACCESSKEY" => "W")); $form->AddInput(array("TYPE" => "text", "NAME" => "home_page", "ID" => "home_page", "ReplacePatterns" => array("^\\s+" => "", "\\s+\$" => "", "^([wW]{3}\\.)" => "http://\\1", "^([^:]+)\$" => "http://\\1", "^(http|https)://(([-!#\$%&'*+.0-9=?A-Z^_`a-z{|}~]+\\.)+[A-Za-z]{2,6}(:[0-9]+)?)\$" => "\\1://\\2/"), "ValidateRegularExpression" => '^(http|https)\\://(([-!#\\$%&\'*+.0-9=?A-Z^_`a-z{|}~]+\\.)+[A-Za-z]{2,6})(\\:[0-9]+)?(/)?/', "ValidationErrorMessage" => "It was not specified a valid home page URL.", "LABEL" => "H<u>o</u>me page", "ACCESSKEY" => "o")); $form->AddInput(array("TYPE" => "text", "NAME" => "alias", "ID" => "alias", "MAXLENGTH" => 20, "Capitalization" => "uppercase", "ValidateRegularExpression" => "^[a-zA-Z0-9]+\$", "ValidateRegularExpressionErrorMessage" => "The alias may only contain letters and digits.", "ValidateAsNotEmpty" => 1, "ValidateAsNotEmptyErrorMessage" => "It was not specified the alias.", "ValidateMinimumLength" => 5, "ValidateMinimumLengthErrorMessage" => "It was not specified an alias shorter than 5 characters.", "LABEL" => "Acce<u>s</u>s name", "ACCESSKEY" => "s")); $form->AddInput(array("TYPE" => "password", "NAME" => "password", "ID" => "password", "ONCHANGE" => "if(value.toLowerCase) value=value.toLowerCase()", "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid password.", "LABEL" => "Passwor<u>d</u>", "ACCESSKEY" => "d", "ReadOnlyMark" => "********")); $form->AddInput(array("TYPE" => "password", "NAME" => "confirm_password", "ID" => "confirm_password", "ONCHANGE" => "if(value.toLowerCase) value=value.toLowerCase()", "ValidateAsEqualTo" => "password", "ValidationErrorMessage" => "The password is not equal to the confirmation.", "LABEL" => "<u>C</u>onfirm password", "ACCESSKEY" => "C", "ReadOnlyMark" => "********")); $form->AddInput(array("TYPE" => "text", "NAME" => "reminder", "ID" => "reminder", "ValidateAsNotEmpty" => 1, "ValidateAsNotEmptyErrorMessage" => "It was not specified a reminder phrase.", "ValidateAsDifferentFrom" => "password", "ValidateAsDifferentFromErrorMessage" => "The reminder phrase may not be equal to the password.", "LABEL" => "Password <u>r</u>eminder", "ACCESSKEY" => "r")); $form->AddInput(array("TYPE" => "select", "MULTIPLE" => 1, "NAME" => "interests", "ID" => "interests", "SELECTED" => array("other"), "SIZE" => 4, "OPTIONS" => array("arts" => "Arts", "business" => "Business", "computers" => "Computers", "education" => "Education", "entertainment" => "Entertainment", "health" => "Health", "news" => "News", "politics" => "Politics", "sports" => "Sports", "science" => "Science", "other" => "Other"), "ValidateAsSet" => 1, "ValidationErrorMessage" => "It were not specified any interests.", "LABEL" => "<u>I</u>nterests", "ACCESSKEY" => "I")); $form->AddInput(array("TYPE" => "checkbox", "NAME" => "notification", "ID" => "email_notification", "VALUE" => "email", "CHECKED" => 0, "MULTIPLE" => 1, "ValidateAsSet" => 1, "ValidateAsSetErrorMessage" => "It were not specified any types of notification.", "LABEL" => "E-<u>m</u>ail", "ACCESSKEY" => "m", "ReadOnlyMark" => "[X]")); $form->AddInput(array("TYPE" => "checkbox", "NAME" => "notification", "ID" => "phone_notification", "VALUE" => "phone", "CHECKED" => 0, "MULTIPLE" => 1, "LABEL" => "P<u>h</u>one", "ACCESSKEY" => "h", "ReadOnlyMark" => "[X]")); $form->AddInput(array("TYPE" => "radio", "NAME" => "subscription_type", "VALUE" => "administrator", "ID" => "administrator_subscription", "ValidateAsSet" => 1, "ValidateAsSetErrorMessage" => "It was not specified the subscription type.", "LABEL" => "Adm<u>i</u>nistrator", "ACCESSKEY" => "i", "ReadOnlyMark" => "[X]")); $form->AddInput(array("TYPE" => "radio", "NAME" => "subscription_type", "VALUE" => "user", "ID" => "user_subscription", "LABEL" => "<u>U</u>ser", "ACCESSKEY" => "U", "ReadOnlyMark" => "[X]"));
* test_upload_progress.php * * @(#) $Header: /home/mlemos/cvsroot/forms/test_upload_progress.php,v 1.7 2008/08/16 05:12:37 mlemos Exp $ * */ require 'forms.php'; require 'form_ajax_submit.php'; require 'form_upload_progress.php'; $form = new form_class(); $form->NAME = 'upload_form'; $form->METHOD = 'POST'; $form->ACTION = ''; $form->ENCTYPE = 'multipart/form-data'; $form->debug = 'error_log'; $form->ResubmitConfirmMessage = 'Are you sure you want to submit this form again?'; $form->AddInput(array('TYPE' => 'file', 'NAME' => 'userfile', 'ValidateAsNotEmpty' => 1, 'ValidationErrorMessage' => 'It was not specified a valid file to upload')); $form->AddInput(array('TYPE' => 'submit', 'VALUE' => 'Upload', 'NAME' => 'doit')); $form->AddInput(array('TYPE' => 'hidden', 'NAME' => 'MAX_FILE_SIZE', 'VALUE' => 1000000)); $form->AddInput(array('TYPE' => 'custom', 'NAME' => 'upload_progress', 'ID' => 'upload_progress', 'FeedbackElement' => 'feedback', 'FeedbackFormat' => '<center> <table style="width: 200px" class="progress_container" border="1"> <tr><td style="width: {ACCURATE_PROGRESS}%;" class="progress_bar"> <tt>{PROGRESS}%</tt></td><td style="border-style: none;"></td> </tr></table><br /> <tt>Uploaded {UPLOADED}B of {TOTAL}B<br /> Remaining time: {REMAINING}<br /> Average speed: {AVERAGE_SPEED}B/s<br /> Current speed: {CURRENT_SPEED}B/s</tt></center>', 'CustomClass' => 'form_upload_progress_class')); /* * Handle client side events on the server side. * Do not output anything before these lines. */
*/ if (defined("__TEST")) { if (isset($__test_options["ShowAllErrors"])) { $form->ShowAllErrors = $__test_options["ShowAllErrors"]; } if (isset($__test_options["today"])) { $today = $__test_options["today"]; } if (isset($__test_options["start_date"])) { $start_date = $__test_options["start_date"]; } if (isset($__test_options["end_date"])) { $end_date = $__test_options["end_date"]; } } $form->AddInput(array("TYPE" => "custom", "ID" => "date", "LABEL" => "<u>D</u>ate", "ACCESSKEY" => "D", "CustomClass" => "form_date_class", "VALUE" => $today, "Format" => "{day}/{month}/{year}", "Months" => array("01" => "January", "02" => "February", "03" => "March", "04" => "April", "05" => "May", "06" => "June", "07" => "July", "08" => "August", "09" => "September", "10" => "October", "11" => "November", "12" => "December"), "Optional" => 1, "ValidationStartDate" => $start_date, "ValidationStartDateErrorMessage" => "It was specified a schedule date before the start date.", "ValidationEndDate" => $end_date, "ValidationEndDateErrorMessage" => "It was specified a schedule date after the end date.")); /* * The following lines are for testing purposes. * Remove these lines when adapting this example to real applications. */ if (defined("__TEST")) { if (isset($__test_options["set_date"])) { $form->SetInputValue('date', $__test_options["set_date"]); echo $form->GetInputValue('date'); return; } } $form->AddInput(array("TYPE" => "submit", "VALUE" => "Schedule", "NAME" => "doit")); $form->LoadInputValues($form->WasSubmitted("doit")); $verify = array(); if ($form->WasSubmitted("doit")) {
*/ if (defined("__TEST")) { if (isset($__test_options["ShowAllErrors"])) { $form->ShowAllErrors = $__test_options["ShowAllErrors"]; } if (isset($__test_options["today"])) { $today = $__test_options["today"]; } if (isset($__test_options["start_date"])) { $start_date = $__test_options["start_date"]; } if (isset($__test_options["end_date"])) { $end_date = $__test_options["end_date"]; } } $form->AddInput(array("TYPE" => "custom", "ID" => "experience", "LABEL" => "Your PHP <u>E</u>xperience", "ACCESSKEY" => "E", "CustomClass" => "form_date_class", "VALUE" => '', "AskAge" => 1, "HideDay" => 1, "FixedDay" => 1, "Format" => "{year} years and {month} months", "ValidationStartDate" => $start_date, "ValidationStartDateErrorMessage" => "You cannot have that long PHP experience as PHP was only released in 1995.", "ValidationEndDate" => $end_date, "ValidationEndDateErrorMessage" => "You have not specified a valid experience period.")); /* * The following lines are for testing purposes. * Remove these lines when adapting this example to real applications. */ if (defined("__TEST")) { if (isset($__test_options["set_date"])) { $form->SetInputValue('experience', $__test_options["set_date"]); echo $form->GetInputValue('experience'); return; } } $form->AddInput(array("TYPE" => "submit", "VALUE" => "Submit", "NAME" => "doit")); $form->LoadInputValues($form->WasSubmitted("doit")); $verify = array(); if ($form->WasSubmitted("doit")) {
/* * test_auto_complete.php * * @(#) $Header: /home/mlemos/cvsroot/forms/test_auto_complete.php,v 1.9 2006/12/20 06:21:16 mlemos Exp $ * */ require 'forms.php'; require 'form_ajax_submit.php'; require 'form_auto_complete.php'; $form = new form_class(); $form->NAME = 'auto_complete_form'; $form->METHOD = 'POST'; $form->ACTION = ''; $form->debug = 'error_log'; $form->AddInput(array('TYPE' => 'text', 'ID' => 'color', 'NAME' => 'color', 'LABEL' => '<u>C</u>olor', 'ACCESSKEY' => 'C', 'VALUE' => '', 'SIZE' => 32, 'ExtraAttributes' => array('autocomplete' => 'off'))); $form->AddInput(array('TYPE' => 'button', 'NAME' => 'show_colors', 'ID' => 'show_colors', 'VALUE' => '...')); $form->AddInput(array('TYPE' => 'custom', 'ID' => 'complete_color', 'NAME' => 'complete_color', 'CustomClass' => 'form_auto_complete_class', 'CompleteInput' => 'color', 'CompleteMinimumLength' => 1, 'CompleteValues' => array('Black' => ' <span style="background-color: black; color: white;">B</span>lack', 'Blue' => '<span style="background-color: blue; color: white;">B</span>lue', 'Cyan' => '<span style="background-color: cyan; color: #000000">C</span>yan', 'Green' => '<span style="background-color: green; color: white;">G</span>reen', 'Magenta' => '<span style="background-color: magenta">M</span>agenta', 'Red' => '<span style="background-color: red">R</span>ed', 'White' => '<span style="background-color: white; color: #000000">W</span>hite', 'Yellow' => '<span style="background-color: yellow; color: #000000">Y</span>ellow'), 'Dynamic' => 1, 'ShowButton' => 'show_colors', 'FeedbackElement' => 'complete_color_feedback', 'SubmitFeedback' => ' <img src="indicator.gif" width="16" height="16" alt="Looking up for colors" title="Looking up for colors" /> ', 'CompleteFeedback' => ' <img src="indicator.gif" width="16" height="16" style="visibility: hidden;" /> ')); $form->AddInput(array('TYPE' => 'text', 'ID' => 'font', 'NAME' => 'font', 'LABEL' => '<u>F</u>ont', 'ACCESSKEY' => 'F', 'VALUE' => '', 'SIZE' => 32, 'ExtraAttributes' => array('autocomplete' => 'off'))); $form->AddInput(array('TYPE' => 'image', 'NAME' => 'show_fonts', 'ID' => 'show_fonts', 'SRC' => 'pulldown.gif', 'ALT' => 'Show fonts', 'ALIGN' => 'top')); $form->AddInput(array('TYPE' => 'custom', 'ID' => 'complete_font', 'NAME' => 'complete_font', 'CustomClass' => 'form_auto_complete_class', 'CompleteInput' => 'font', 'CompleteMinimumLength' => 1, 'CompleteValues' => array('sans-serif' => '<span style="font-family: sans-serif; float: right">ABC</span>Sans Serif', 'serif' => '<span style="font-family: serif; float: right">ABC</span>Serif', 'cursive' => '<span style="font-family: cursive; float: right">ABC</span>Cursive', 'fantasy' => '<span style="font-family: fantasy; float: right">ABC</span>Fantasy', 'monospace' => '<span style="font-family: monospace; float: right">ABC</span>Monospace'), 'Dynamic' => 0, 'MenuStyle' => '', 'MenuClass' => 'groovymenu', 'ItemStyle' => '', 'SelectedItemStyle' => '', 'ItemClass' => 'groovyitem', 'SelectedItemClass' => 'groovyselecteditem', 'ShowButton' => 'show_fonts')); /* * This code is necessary to handle the requests for fetching * auto-complete values. */ $form->HandleEvent($processed); if ($processed) { exit;
* This example serves to demonstrate how to develop a custom input that * implements a new type of validation not supported by the main forms class. * * @(#) $Id: $ * */ require 'forms.php'; require 'form_custom_validation.php'; $form = new form_class(); $form->NAME = 'custom_validation_form'; $form->METHOD = 'POST'; $form->ACTION = ''; $form->InvalidCLASS = 'invalid'; $form->ShowAllErrors = 0; $form->debug = 'trigger_error'; $form->AddInput(array('TYPE' => 'text', 'ID' => 'first', 'NAME' => 'first', 'LABEL' => '<u>F</u>irst name', 'ACCESSKEY' => 'F', 'ValidateAsNotEmpty' => 1, 'ValidationErrorMessage' => 'It was not specified a valid first name.')); $form->AddInput(array('TYPE' => 'text', 'ID' => 'second', 'NAME' => 'second', 'LABEL' => '<u>S</u>econd name', 'ACCESSKEY' => 'S', 'ValidateAsNotEmpty' => 1, 'ValidationErrorMessage' => 'It was not specified a valid second name.')); /* * Add a custom input that will be used only for validation purposes */ $error = $form->AddInput(array('TYPE' => 'custom', 'ID' => 'validation', 'CustomClass' => 'form_custom_validation_class', 'FirstInput' => 'first', 'FirstValidationErrorMessage' => 'The first name is contained in the second name.', 'SecondInput' => 'second', 'SecondValidationErrorMessage' => 'The second name is contained in the first name.')); /* * If something went wrong, probably due to missing or invalid parameters, * it is safer to exit the script so the rest of the script does not execute */ if (strlen($error)) { die('Error: ' . $error); } $form->AddInput(array('TYPE' => 'submit', 'VALUE' => 'Submit', 'NAME' => 'doit')); /* * The following lines are for testing purposes.
<?php /* * * @(#) $Id: test_html_editor.php,v 1.6 2009/09/26 06:12:06 mlemos Exp $ * */ require 'forms.php'; require 'form_html_editor.php'; $form = new form_class(); $form->NAME = 'html_editor_form'; $form->METHOD = 'POST'; $form->ACTION = ''; $form->ONSUBMIT = 'return false'; $form->debug = 'trigger_error'; $form->AddInput(array('TYPE' => 'custom', 'ID' => 'editor', 'CustomClass' => 'form_html_editor_class', 'NAME' => 'editor', 'ROWS' => 20, 'COLS' => 80, 'VALUE' => '<h1>Hello world!</h1>{menu sad}<p>{smiley}</p>', 'Debug' => 1, 'STYLE' => 'width: 800px; height: 600px; background-color: #ffffff; border-style: solid; border-width: 1px; margin: 0px; border-color: #707070 #e0e0e0 #e0e0e0 #707070', 'JavascriptPath' => '', 'TemplateVariables' => array('menu' => array('Preview' => '<a href="">File</a> <a href="">Edit</a> <a href="">Tools</a> <a href="">Help</a>', 'Inline' => 0, 'Title' => 'Menu', 'Alternatives' => array('vertical' => array('Preview' => '<a href="">File</a><br /><a href="">Edit</a><br /><a href="">Tools</a><br /><a href="">Help</a>', 'Title' => 'Vertical menu'))), 'smiley' => array('Preview' => ';-)', 'Inline' => 1, 'Title' => 'Smiley', 'Alternatives' => array('sad' => array('Preview' => ':-(', 'Title' => 'Sad'), 'grin' => array('Preview' => ':D', 'Title' => 'Grin'), 'shocked' => array('Preview' => ':O', 'Title' => 'Shocked')))))); $form->AddInput(array('TYPE' => 'submit', 'ID' => 'send', 'NAME' => 'send', 'VALUE' => 'Submit')); $head = $form->PageHead(); $onload = $form->PageLoad(); $onunload = $form->PageUnload(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test for Manuel Lemos' PHP form class using the HTML editor plug-in</title> <?php echo $head; ?> <style type="text/css"> .editor { background-color: blue; font-family: "courier" }
* test_linked_select.php * * @(#) $Header: /home/mlemos/cvsroot/forms/test_linked_select.php,v 1.7 2006/12/20 06:21:16 mlemos Exp $ * */ require "forms.php"; require "form_linked_select.php"; $continents = array("" => "Select continent", "na" => "North America", "eu" => "Europe", "sa" => "South America", "as" => "Asia", "oc" => "Oceania"); $countries = array("" => array("" => "Select country"), "na" => array("" => "Select country", "us" => "United States", "ca" => "Canada"), "eu" => array("" => "Select country", "pt" => "Portugal", "de" => "Germany"), "sa" => array("" => "Select country", "br" => "Brazil", "ar" => "Argentina"), "as" => array("" => "Select country", "jp" => "Japan", "kr" => "Korea"), "oc" => array("" => "Select country", "au" => "Australia", "nz" => "New Zeland")); $locations = array("" => array("" => "Select location"), "us" => array("" => "Select location", "ny" => "New York", "la" => "Los Angeles"), "ca" => array("" => "Select location", "to" => "Toronto", "mo" => "Montréal"), "pt" => array("" => "Select location", "li" => "Lisbon", "av" => "Aveiro"), "de" => array("" => "Select location", "fr" => "Frankfurt", "be" => "Berlin"), "br" => array("" => "Select location", "sa" => "São Paulo", "ri" => "Rio de Janeiro"), "ar" => array("" => "Select location", "bu" => "Buenos Aires", "ma" => "Mar del Plata"), "jp" => array("" => "Select location", "to" => "Tokio", "os" => "Osaka"), "kr" => array("" => "Select location", "se" => "Seoul", "yo" => "Yosu"), "au" => array("" => "Select location", "sy" => "Sydney", "me" => "Melbourne"), "nz" => array("" => "Select location", "we" => "Wellington", "au" => "Auckland")); $form = new form_class(); $form->NAME = "location_form"; $form->METHOD = "POST"; $form->ACTION = ""; $form->debug = "error_log"; $form->AddInput(array("TYPE" => "select", "ID" => "continent", "NAME" => "continent", "LABEL" => "<u>C</u>ontinent", "ACCESSKEY" => "C", "VALUE" => "", "OPTIONS" => $continents, "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid continent.")); $form->AddInput(array("TYPE" => "custom", "ID" => "country", "NAME" => "country", "LABEL" => "Coun<u>t</u>ry", "ACCESSKEY" => "t", "CustomClass" => "form_linked_select_class", "VALUE" => "", "Groups" => $countries, "LinkedInput" => "continent", "AutoWidthLimit" => 0, "AutoHeightLimit" => 0, "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid country.")); $form->AddInput(array("TYPE" => "custom", "ID" => "location", "NAME" => "location", "LABEL" => "<u>L</u>ocation", "ACCESSKEY" => "L", "CustomClass" => "form_linked_select_class", "VALUE" => "", "Groups" => $locations, "LinkedInput" => "country", "AutoWidthLimit" => 0, "AutoHeightLimit" => 0, "ValidateAsNotEmpty" => 1, "ValidationErrorMessage" => "It was not specified a valid location.")); $form->AddInput(array("TYPE" => "submit", "VALUE" => ">", "NAME" => "update", "SubForm" => "update")); $form->AddInput(array("TYPE" => "submit", "VALUE" => "Go", "NAME" => "doit")); $form->Connect("location", "doit", "ONCHANGE", "Click", array()); /* * This code is necessary to handle the requests for serving the * dynamically generated lists of options for linked select inputs. */ $form->HandleEvent($processed); if ($processed) { exit; } $form->LoadInputValues($form->WasSubmitted("doit")); $verify = array();
<?php /* * * @(#) $Id: test_animation.php,v 1.4 2008/09/07 06:24:27 mlemos Exp $ * */ require 'forms.php'; require 'form_animation.php'; $form = new form_class(); $form->NAME = 'animation_form'; $form->METHOD = 'POST'; $form->ACTION = ''; $form->debug = 'trigger_error'; $form->AddInput(array('TYPE' => 'custom', 'ID' => 'animation', 'CustomClass' => 'form_animation_class', 'JavascriptPath' => '')); $form->AddInput(array('TYPE' => 'button', 'ID' => 'show', 'VALUE' => 'fade in')); $form->AddInput(array('TYPE' => 'button', 'ID' => 'hide', 'VALUE' => 'fade out')); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test for Manuel Lemos' PHP form class using the animation plug-in</title> <?php echo $form->PageHead(); ?> </head> <body bgcolor="#cccccc"> <center><h1>Test for Manuel Lemos' PHP form class using the animation plug-in</h1></center> <hr />
require 'form_auto_complete.php'; require 'form_mysql_auto_complete.php'; $host = "localhost"; $user = "******"; $password = "******"; $database = "medicus"; $connection = @mysql_pconnect($host, $user, $password); if ($connection) { mysql_select_db($database, $connection); } $form = new form_class(); $form->NAME = 'auto_complete_form'; $form->METHOD = 'POST'; $form->ACTION = ''; $form->debug = 'error_log'; $form->AddInput(array('TYPE' => 'text', 'ID' => 'location', 'NAME' => 'location', 'LABEL' => '<u>L</u>ocation', 'ACCESSKEY' => 'L', 'VALUE' => '', 'ExtraAttributes' => array('autocomplete' => 'off', 'title' => 'Type just the first letters of a location.'))); $form->AddInput(array('TYPE' => 'button', 'NAME' => 'show_locations', 'ID' => 'show_locations', 'VALUE' => '...', 'ExtraAttributes' => array('title' => 'Click to show all locations.'))); $form->AddInput(array('TYPE' => 'custom', 'ID' => 'complete_location', 'NAME' => 'complete_location', 'CustomClass' => 'form_mysql_auto_complete_class', 'CompleteInput' => 'location', 'CompleteMinimumLength' => 1, 'Dynamic' => 1, 'ShowButton' => 'show_locations', "Connection" => $connection, "CompleteValuesQuery" => "SELECT nazwa FROM sl_bloz WHERE nazwa {BEGINSWITH} ORDER BY nazwa", "CompleteValuesLimit" => 10, 'FeedbackElement' => 'complete_location_feedback', 'SubmitFeedback' => ' <img src="indicator.gif" width="16" height="16" alt="Looking up for locations" title="Looking up for locations" /> ', 'CompleteFeedback' => ' <img src="indicator.gif" width="16" height="16" style="visibility: hidden;" /> ', 'MenuClass' => 'groovymenu', 'MenuStyle' => '', 'ItemClass' => 'groovyitem', 'ItemStyle' => '', 'SelectedItemClass' => 'groovyselecteditem', 'SelectedItemStyle' => '')); /* * This code is necessary to handle the requests for fetching * auto-complete values. */ $form->HandleEvent($processed); if ($processed) { exit; } $form->ConnectFormToInput('location', 'ONLOAD', 'Focus', array()); $onload = HtmlSpecialChars($form->PageLoad()); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
<?php /* * * @(#) $Id: test_captcha_input.php,v 1.9 2006/12/20 06:21:16 mlemos Exp $ * */ require "forms.php"; require "form_captcha.php"; $key = "my secret key"; $form = new form_class(); $form->NAME = "captcha_form"; $form->METHOD = "POST"; $form->ACTION = ""; $form->debug = "error_log"; $error = $form->AddInput(array("TYPE" => "custom", "ID" => "captcha", "LABEL" => "<u>E</u>nter the following text:", "ACCESSKEY" => "E", "CustomClass" => "form_captcha_class", "Key" => $key, "ImageFormat" => "png", "NoiseFromPNGImage" => "noise.png", "ResetIncorrectText" => 1, "BackgroundColor" => "#FFFFFF", "ValidationErrorMessage" => "It was not entered the correct text.", "ExpiryTime" => 60, "ExpiryTimeValidationErrorMessage" => "The validation text has expired.")); if (strlen($error)) { die("Error: " . $error); } $form->AddInput(array("TYPE" => "submit", "VALUE" => "Submit", "NAME" => "doit")); /* * This code is necessary to handle the requests for serving the captcha * image. * Do not remove it nor output any data or headers before these lines. */ $form->HandleEvent($processed); if ($processed) { exit; } $form->LoadInputValues($form->WasSubmitted("doit")); $verify = array();
/* * This example serves to demonstrate how to validate an input depending * on the state of another input. * * @(#) $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; }
$form->ShowAllErrors = 1; $form->ErrorMessagePrefix = '- '; $form->debug = 'trigger_error'; /* * Include the blog post model class and initialize the object to store * and retrieve data of the post entries being edited */ require 'blog_post_model.php'; $model = new blog_post_model_class(); if (!$model->Initialize()) { die('Error: ' . $model->error); } /* * Add the scaffolding custom input with all the necessary properties */ $error = $form->AddInput(array('TYPE' => 'custom', 'CustomClass' => 'form_scaffolding_class', 'ID' => 'posts', 'ListingMessage' => 'All blog posts', 'NoEntriesMessage' => 'No blog articles were submitted.', 'CreateMessage' => 'Submit a new blog post', 'CreateCanceledMessage' => 'Submitting the blog post was canceled.', 'CreatedMessage' => 'The new blog post was submitted successfully.', 'UpdateMessage' => 'Update this blog post', 'UpdateCanceledMessage' => 'Updating the blog post was canceled.', 'UpdatedMessage' => 'The blog post was updated successfully.', 'DeleteMessage' => 'Are you sure you want to delete this blog post?', 'DeleteCanceledMessage' => 'Deleting the blog post was canceled.', 'DeletedMessage' => 'The blog post was deleted successfully.', 'Preview' => 1, 'PreviewLabel' => 'Preview', 'CreatePreviewMessage' => 'New blog post preview', 'UpdatePreviewMessage' => 'Blog post update preview', 'Save' => 1, 'SaveLabel' => 'Save', 'View' => 1, 'ViewLabel' => 'View', 'ViewingMessage' => 'Viewing blog post', 'EntryFields' => array(array('TYPE' => 'text', 'NAME' => 'title', 'LABEL' => '<u>T</u>itle', 'ValidateAsNotEmpty' => 1, 'ValidationErrorMessage' => 'It was not entered a valid post title.'), array('TYPE' => 'textarea', 'NAME' => 'body', 'LABEL' => '<u>B</u>ody', 'COLS' => 60, 'ROWS' => 10, 'ValidateAsNotEmpty' => 1, 'ValidationErrorMessage' => 'It was not entered a valid post body.')), 'ListingClass' => 'listing box', 'HighlightRowListingClass' => 'highlightrow', 'OddRowListingClass' => 'oddrow', 'EvenRowListingClass' => 'evenrow', 'ErrorMessageFormat' => $view->GetErrorMessageFormat(), 'InvalidMark' => $view->GetInvalidMark(), 'FormHeader' => $view->GetFormHeader(), 'FormFooter' => $view->GetFormFooter())); if (strlen($error)) { die('Error: ' . $error); } /* * Handle events AJAX requests handling events. * Do not output anything nor send any headers before this line. */ $form->HandleEvent($processed); /* * Exit your script if all AJAX events were processed. */ if ($processed) { exit; } /*