PHP form validation question?

Posted by GeNx on Stack Overflow See other posts from Stack Overflow or by GeNx
Published on 2010-03-25T06:20:58Z Indexed on 2010/03/25 6:23 UTC
Read the original article Hit count: 351

Filed under:
|

I have a form that validates the email address and I want to be able to place echo '<p class="error">Please enter a valid email address!</p>'; anywhere on the web page without having to put the validation process within the html?

Or should I include the validation process in the HTML form?

Here is the php code.

if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $_POST['email'])) {
    $email = mysqli_real_escape_string($mysqli, strip_tags($_POST['email']));
} else {
    echo '<p class="error">Please enter a valid email address!</p>';
}

© Stack Overflow or respective owner

PHP form validation question?

Posted by GeNx on Stack Overflow See other posts from Stack Overflow or by GeNx
Published on 2010-03-25T08:04:01Z Indexed on 2010/03/25 8:13 UTC
Read the original article Hit count: 351

Filed under:
|

Is it necessary to validate a name or street address? when I have it coded in the following format. And if so why?

$address = mysqli_real_escape_string($mysqli, htmlentities($_POST['address']));
$name = mysqli_real_escape_string($mysqli, htmlentities($_POST['name']));

© Stack Overflow or respective owner

Related posts about php

Related posts about validation