$form->addElement(array('type' => 'textarea', 'name' => 'ct_message', 'label' => 'Write message:*', 'attributes' => array('rows' => 7), 'validate' => 'required')); /* ADDING A SUBMIT BUTTON */ $form->addElement(array('type' => 'submit', 'name' => 'ct_contact_me', 'value' => 'Submit', 'parentEl' => array('style' => 'text-align:right;'))); $err_msg = ''; $sent = false; if (isset($_POST['ct_contact_me'])) { $validate = $form->validate(); // validate the form if (!$validate['isValid']) { $err_msg = '<div class="errMsg" style="text-align:center;width:' . $options['form_width'] . '"> Something went wrong. Please review the form!</div><br>'; } else { $mail_body = "Firstname: " . $_POST['ct_firstname'] . "\n"; $mail_body .= "Lastname: " . $_POST['ct_lastname'] . "\n"; $mail_body .= "Email: " . $_POST['ct_email'] . "\n"; $mail_body .= "Phone: " . $_POST['ct_phone'] . "\n"; $mail_body .= "Reason: " . $_POST['ct_reason'] . "\n"; $mail_body .= "Message: " . $_POST['ct_message'] . "\n"; mail($email_address, $mail_subject, $mail_body); echo "Form has been sent..."; $sent = true; } } echo '</head><body>'; if (!$sent) { echo '<div style="text-align:center;width:' . $options['form_width'] . '"><h1>Contact Form</h1></div>'; echo $err_msg; /* FINALLY RENDER THE FORM */ $test = $form->render(); } echo '</body></html>';
Wrong user ID or password!</div><br>'; } else { $_SESSION['loggedIn'] = true; if (@$_POST['lg_keep_login']) { setcookie("cookname", $user, time() + 60 * 60 * 24 * 100, "/"); setcookie("cookpass", $pass, time() + 60 * 60 * 24 * 100, "/"); } header('Location: ' . $redirect_page); exit; } } echo '</head><body>'; echo '<div style="text-align:center;width:' . $options['form_width'] . '"><h1>Login Form</h1></div>'; echo $err_msg; /* FINALLY RENDER THE FORM */ $form->render(array('id' => 'loginForm')); echo '</body></html>'; /* CHECK IF USER CAN LOGIN, A CUSTOM FUNCTION ADDED TO THE SERVER SIDE VALIDATOR */ function check_login() { ### THE FOLLOWING LINES COULD BE REPLACED WITH A SQL QUERY ############ global $user, $pass; return $_POST['lg_username'] != $user || @md5($_POST['lg_password']) != $pass ? false : true; ########################################################### } /* USE THIS FUNCTION IN THE HEADER OF THE PAGES IN THE PROTECTED AREA * TO CHECK IF USER HAS ACCESS */ /*function check_user() { if(!@$_SESSION['loggedIn'])
/* ADDING A FIELDSET AS CONTAINER FOR THE PREVIOUS FIELDS */ $form->addElement(array('type' => 'fieldset', 'name' => 'reg_fieldset', 'label' => 'User Registration Form', 'values' => array('spacer1', 'reg_name', 'reg_password', 'reg_password1', 'reg_email'), 'attributes' => array('style' => 'padding:10px;'))); /* ADDING A RADIOGROUP */ $form->addElement(array('type' => 'radiogroup', 'name' => 'reg_newsletter', 'values' => array('yes' => 'Yes !!! (please)', 'no' => 'No (thank you)'), 'labelOptions[]' => array('align' => 'right'), 'attributes[yes]' => array('checked' => true), 'validate' => 'required')); /* ADDING A SPACER */ $form->addElement(array('type' => 'custom', 'name' => 'spacer2', 'value' => $form->addSpacer('1px'))); /* ADDING A FIELDSET AS CONTAINER FOR THE PREVIOUS FIELDS */ $form->addElement(array('type' => 'fieldset', 'name' => 'reg_fieldset1', 'label' => 'Signup for our newsletter', 'values' => array('spacer2', 'reg_newsletter'), 'attributes' => array('style' => 'padding:10px;'))); /* ADDING A SUBMIT BUTTON */ $form->addElement(array('type' => 'submit', 'name' => 'reg_send', 'value' => 'Register', 'parentEl' => array('style' => 'text-align:right;'))); echo '</head><body> <div id="switcher"></div>'; $ok = false; $err_msg = ''; if (isset($_POST['reg_send'])) { $validate = $form->validate(); // validate the form with php if (!$validate['isValid']) { $err_msg = '<div class="errMsg" style="text-align:center;width:' . $options['form_width'] . '"> Something went wrong. Please review the form!</div><br>'; } else { $ok = true; echo '<span>New account created!</span>'; } } if (!$ok) { echo '<div><h1>New User Registration</h1></div>'; echo $err_msg; $form->render(); } echo '</body></html>';