Prev | Current Page 631 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

The problem is compounded with most users??™
lack of understanding regarding what constitutes a valid address. For example, which of
the following three e-mail addresses are invalid?
john++ilove-pizza@example.com
john&sally4ever@example.com
i.brake4_pizza@example.co.uk
You might be surprised to learn they??™re all valid! If you don??™t know this and attempt
to implement an e-mail validation function, it??™s possible you could prevent a perfectly
valid e-mail address from being processed. Why not leave it to the Validate package?
Consider this example:
// Include the Validate package
require_once "Validate.php";
// Retrieve the provided e-mail address
$email = $_POST['email'];
// Instantiate the Validate class
$validate = new Validate();
// Determine if address is valid
if($validate->email($email))
echo "Valid e-mail address!";
else
echo "Invalid e-mail address!";
?>
You can also determine whether the address domain exists by passing the option
check_domain as a second parameter to the email() method, like this:
$validate->email($email, array("check_domain" => 1));
CHAPTER 21 ?–  SECURE PHP PROGRAMMING 559
Data Encryption
Encryption can be defined as the translation of data into a format that is intended to
be unreadable by anyone except the intended party. The intended party can then
decode, or decrypt, the encrypted data through the use of some secret??”typically a
secret key or password.


Pages:
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643