<?php #create form object $profile = new Formitable($db, 'sionapros_users'); #set primary key field $profile->setPrimaryKey('identifier'); $profile->setEncryptionKey("EHm1C_3nCr4p7"); $persNoSQL = "SELECT identifier FROM sionapros_users WHERE username = '******'loginUsername']}'"; $res = $db->execute($persNoSQL); #retrieve profile's data $profile->getRecord($res[0]['identifier']); #hide primary key field $profile->hideField('identifier'); #customiszing form $profile->hideField('reg_date'); $profile->hideField('identifier'); $profile->hideField('username'); $profile->hideField('password'); $profile->hideField('change_password'); $profile->hideFields(array('account_status')); #custom labels $profile->labelFields(array('firstname', 'lastname'), array('First Name *', 'Last Name *')); //set up regular expressions for field validation $profile->registerValidation("required", ".+", "Input is required."); //set up fields for validation using regexs above $profile->validateField("firstname", "required"); $profile->validateField("lastname", "required"); #set default values #submit msg $profile->msg_updateSuccess = "Your Profile was updated successfully."; //set all output to be returned instead of printed
<?php #get staff personnel_no #$staff_no = $_GET['identifier']; if (isset($_GET['identifier'])) { $_SESSION['upd_no'] = $_GET['identifier']; } #create form object $staff = new Formitable($db, 'sionapros_users'); #set primary key field $staff->setPrimaryKey('identifier'); $staff->setEncryptionKey("qHm1rC_3nCt4p7"); #retrieve staff's data $staff->getRecord($_SESSION['upd_no']); #hide primary key field $staff->hideField('identifier'); #customiszing form $staff->hideField('reg_date'); $staff->hideField('identifier'); $staff->hideField('username'); $staff->hideField('password'); $staff->forceTypes(array('account_status', 'change_password'), array('select', 'select')); #custom labels $staff->labelFields(array('firstname', 'lastname'), array('First Name *', 'Last Name *')); $staff->labelFields(array('account_status', 'change_password'), array('Account Status *', 'Change Password *')); //set up regular expressions for field validation $staff->registerValidation("required", ".+", "Field MUST be filled in please."); //set up fields for validation using regexs above $staff->validateField("firstname", "required"); $staff->validateField("lastname", "required"); $staff->validateField("change_password", "required");
$newForm->forceTypes(array("foods", "day_of_week"), array("checkbox", "radio")); //get data pairs from another table $newForm->normalizedField("toon", "formitable_toons", "ID", "name", "pkey ASC"); //set custom field labels $newForm->labelFields(array("f_name", "l_name", "description", "pets", "foods", "color", "day_of_week", "b_day", "toon"), array("First Name", "Last Name", "About Yourself", "Your Pets", "Favorite Foods", "Favorite Color", "Favorite Day", "Your Birthday", "Favorite Cartoon")); //set some default values $newForm->setDefaultValue("pets", "Dog"); $newForm->setDefaultValue("color", "Blue"); $newForm->setDefaultValue("toon", "3"); $newForm->setDefaultValue("foods", "pizza,salad"); $newForm->setDefaultValue("day_of_week", date("l")); //set up regular expressions for field validation $newForm->registerValidation("required", ".+", "Input is required."); //set up a field for validation using regex above $newForm->validateField("f_name", "required"); //set validation feedback mode $newForm->feedback = "both"; //retrieve a record for update if GET var set if (isset($_GET['ID'])) { $newForm->getRecord($_GET['ID']); } //call submit method if form has been submitted if (!isset($_POST['submit']) || isset($_POST['submit']) && $newForm->submitForm() == -1) { $newForm->printForm(); } ?> </div> </center> </body></html>
<?php $id = $_REQUEST['id']; #$faq = new Allergy($db); #create form object $faq = new Formitable($db, 'sionapros_faqs'); $faq->setPrimaryKey('id'); $faq->getRecord($id); $faq->forceTypes(array('id', 'done_by', 'reg_date', 'category'), array('hidden', 'hidden', 'hidden', 'select')); #custom labels $faq->labelFields(array('faq_qn', 'faq_ans', 'category'), array('Question *', 'Answer *', 'Category *')); //set up regular expressions for field validation $faq->registerValidation("required", ".+", "Field MUST be filled in please."); //set up fields for validation using regexs above $faq->registerValidation("required", ".+", "Field MUST be filled in please."); //set up fields for validation using regexs above $faq->validateField("faq_qn", "required"); $faq->validateField("faq_ans", "required"); $faq->validateField("category", "required"); #set default values $faq->setDefaultValue('done_by', $_SESSION['loginUsername']); #normalized field $faq->normalizedField("category", "sionapros_categories", "id", "value", "id ASC"); //set all output to be returned instead of printed $faq->returnOutput = true; if (!isset($_POST['submit']) || isset($_POST['submit']) && $faq->submitForm(false) == -1) { $faqForm = $faq->printForm(); $smarty->assign('faq', $faqForm); } else { $smarty->assign('updateMsg', $faq->submitMsg); #unset prevPath
<?php #get the ward_no $news_no = $_REQUEST['news_no']; #create form object $news = new Formitable($db, 'sionapros_news'); #set primary key field $news->setPrimaryKey('news_no'); $news->setEncryptionKey("eoeeuye_eeeoi"); $news->getRecord($news_no); $news->forceType('news_no', 'hidden'); $news->forceType('photo', 'hidden'); $news->forceType('category', 'select'); $news->hideFields(array('photo_desc', 'reg_date', 'username')); $news->setDateField('pub_date'); #$news->forceTypes(array('status'), array('select')); #custom labels $news->labelFields(array('title', 'summary', 'detail', 'category', 'pub_date'), array('Title *', 'News Summary*', 'Details *', 'Category *', 'Publication Date *')); //set up regular expressions for field validation $news->registerValidation("required", ".+", "Field MUST be filled in please."); //set up fields for validation using regexs above $news->validateField("title", "required"); $news->validateField("summary", "required"); $news->validateField("category", "required"); $news->validateField("pub_date", "validateDate"); $news->normalizedField("category", "sionapros_categories", "id", "value", "id ASC"); //set all output to be returned instead of printed $news->returnOutput = true; if (!isset($_POST['submit']) || isset($_POST['submit']) && $news->submitForm(false) == -1) { $newsForm = $news->printForm(); $smarty->assign('news', $newsForm);
mysql_query("SET CHARACTER SET 'utf8'", $myconn); // initialize Formitable $newForm = new Formitable($myconn, $prDbname, $prTable); $newForm->setPrimaryKey("id"); // if form has been submitted, call Formitable submit method if (isset($_POST['submit'])) { // if not admin, skip (don't update) the following fields if (!$admin) { $skipped = array('emails1', 'schnip', 'dimo', 'sch1', 'sch2'); $newForm->skipFields($skipped); } $newForm->submitForm(); } else { //retrieve a record for update if GET var is set if (isset($_GET['id'])) { $newForm->getRecord($_GET['id']); } else { die("Error...(no get var)"); } // check if school or admin, else die if (!$admin) { $email = $newForm->getFieldValue('emails1'); if (!strcmp($email, $_SESSION['email1']) || !strcmp($email, $_SESSION['email2'])) { } else { $errormsg = iconv('Windows-1253', 'UTF-8', '<h2>Λάθος. Δεν έχετε δικαίωμα να δείτε αυτό το πρόγραμμα...</h2>'); die($errormsg); } } $title = $newForm->getFieldValue('titel'); $updated = $newForm->getFieldValue('timestamp'); echo iconv('Windows-1253', 'UTF-8', "<h1><i>Πρόγραμμα:</i> ") . $title . "</h1>";
if ($_GET['news_no']) { $_SESSION['news_no'] = $_GET['news_no']; } #check to see that the selected news article has no photo already uploaded $SQL = "SELECT photo FROM sionapros_news WHERE news_no = '{$_SESSION['news_no']}'"; $photo = $db->execute($SQL); if (count($photo) == 0) { } else { $smarty->assign('secMsg', 'Not Allowed'); } #create form object $news = new Formitable($db, 'sionapros_news'); $news->setPrimaryKey('news_no'); #set encryption key $news->setEncryptionKey("eoeeuye_eeeoi"); $news->getRecord($_SESSION['news_no']); $news->forceTypes(array('news_no', 'photo', 'title', 'summary', 'details', 'username', 'reg_date', 'category', 'pub_date'), array('hidden', 'file', 'hidden', 'hidden', 'hidden', 'hidden', 'hidden', 'hidden', 'hidden')); #custom labels $news->labelFields(array('photo', 'photo_desc'), array('Upload A Photo *', 'Short Photo Description *')); //set up regular expressions for field validation $news->registerValidation("required", ".+", "Field MUST be filled in please."); //set up fields for validation using regexs above $news->validateField("photo", "required"); $news->validateField("photo_desc", "required"); #set default values $news->setDefaultValue('news_no', $_SESSION['news_no']); #submit msg $news->msg_updateSuccess = "A photo for a news article was uploaded."; //set all output to be returned instead of printed $news->returnOutput = true; if (isset($_FILES)) {
$newForm->registerValidation("six_chars", ".{6,}", "Enter at least six characters."); //set up fields for validation using regexs above $newForm->validateField("FName", "required"); $newForm->validateField("Email", "valid_email"); $newForm->validateField("Donation_Amount", "currency_us"); $newForm->validateField("Password", "six_chars"); //require the email field to be unique in the database (doesn't already exist) $newForm->uniqueField("Email", "Email is already registered."); print_r($newForm->validate); //set custom success message for update (after last page) $newForm->msg_updateSuccess = "<center><div style=\"width:455; padding:15px; background-color:#F1F3F3;\">\n<p>Registration is now complete. Thanks for joining!</p></div></center>"; //set an encryption key so the record ID is encrypted to prevent tampering $newForm->setEncryptionKey("g00D_3nCr4p7"); //retrieve record if get ID or post pkeyID if (isset($_GET['ID'])) { $newForm->getRecord($_GET['ID']); } else { if (isset($_POST['pkey'])) { $newForm->getRecord($_POST['pkey'], isset($newForm->rc4key)); } } //output a feedback box at the top, and a line above each invalid field #$newForm->feedback="both"; //test for last page and no errors to submit form, otherwise start form if (@$_POST['formitable_multipage'] != "end" || isset($newForm->errMsg)) { $newForm->openForm(); } else { $newForm->submitForm(); } #print_r($newForm->errMsg); //first page - test for no submit OR errors set with a field on the first page