nthomp
-
Posts
2 -
Joined
-
Last visited
Never
Posts posted by nthomp
-
-
You are telling the form to validate but you have not set any rules.
Here is an example using your code
"<?php
require_once "HTML/QuickForm.php";
$form = new HTML_QuickForm('frmTest', 'get');
$form->addElement('header', 'hdrQuickformtest',
'QuickForm Example 2');
$form->addElement('text', 'txtName',
'What is your name?');
//Validation Rules
$form->addRule('text', 'This box is required', required); //this would be server side vaildation
$form->addRule('text', "There are too many characters', 'maxlength', 12, 'client); //This example html_quickform would create the proper javascript to validate client side
$form->addElement('reset', 'btnClear',
'Clear');
$form->addElement('submit', 'btnSubmit',
'Submit');
if ($form->validate()) {
# If the form validates then freeze the data
$form->freeze();
}
$form->display();
?>
Help Pear HTTP::redirect
in PHP Coding Help
Posted
Both servers have PHP5.1.2 and HTTP 1.4.0.
Any ideas what is going on
Code:
<?php
require_once('HTML/QuickForm.php');
include('inc/db.php');
require_once('HTTP.php');
//Function
function login() {
$result = user_login($_POST['username'], $_POST['password']);
if ($result != 'Correct') {
$login_fail = $result;
HTTP::redirect("login.php");
}
else {
HTTP::redirect("index.php");
}
}
//Display Form
$form = new HTML_QuickForm('frmTest', 'post');
//Header
$form->addElement('header', 'MyHeader', 'Please Login');
//Form Input
$form->addElement('text', 'username', 'Username');
$form->addElement('password', 'password', 'Password');
//Submit
$form->addElement('submit', 'btnSubmit', 'Submit');
//PHP Validation
$form->addRule('username', 'Your name is required', 'required');
$form->addRule('password', 'Your password is required', 'required');
//Example of Javascript validation
$form->addRule('password', 'Maximum postcode 8 characters', 'maxlength', 8, 'client');
//Checking Validation
if ($form->validate()) {
# If the form validates then freeze the data
$form->freeze();
$form->process('login', false);
echo "\n<HR>\n";
}
$form->display();
?>