Quote:
|
Originally Posted by cocofried
I am looking for a code for a form checker.
|
I do not think you need to reinvent the wheel. The
PEAR HTML_QuickForm class (API) does it for you.
The following code is a start ( I cannot reproduce the complete code since it is cut from:
The PHP Anthology: Object Oriented PHP Solutions chapter 9.
<?php
require_once ("HTML/QuickForm.php"); //Pear must be in your path (php.ini).
function cmpPass($element, $confirmPass)
{
global $form;
$password = $form->getElementValue('password');
return ($password == $confirmPass);
}
// A function to apply mysql_real_escape_string
function escapeValue($value) {
return mysql_real_escape_string($value);
}
// A function to encrypt the password
function encryptValue($value) {
return md5($value);
}
// Instantiate the QuickForm class
$form = new HTML_QuickForm('regForm', 'POST');
// Register the compare function
$form->registerRule('compare', 'function', 'cmpPass');
.................................................. ......................
?>
Volume II chapter 1 has more advanced access control and authentication systems. Here is an article related to that chapter.
The PHP Anthology Volume 2, Chapter 1 - Access Control
NOTE: Everything you send over the internet in plain text may be hijacked by a packet sniffer. When you send confidential information such as financial details, use an encryption technology such as SSL, eg.
OpenSSL.