Using regular expressions to validate and email

Hello Everyone!

I am working on an assignment for my class that is due tomorrow. I am trying to set up my page to look like this: https://yorktown.cbe.wwu.edu/sandvig/mis314/assignments/a04/Validate.php?

My e-mail address section is not working. It says there is an error i my code. I have attached a utilities page to include in my code. Would someone be willing to tell me why my code isn’t working and where I went wrong?

Here is my utilities section for the email:
function fIsEmail($email) {
$email = trim($email);
// acceptable email address format. This simplified pattern will
// allow some invalid addresses.
// i at end of pattern indicates case-insensitive match
$pattern = “/^[^@]+@[a-z0-9.]+.[a-z]{2,4}$/i”;
//returns count of matching strings
return (preg_match($pattern, $email));
}

And here is my php code in relation to the validate email section:

Email: <?php if ($postback &&!regular expressions--preg_match($email)) { echo "Please enter valid email."; $pageValid = false; } //NOT SURE WHAT THE PROBLEM IS OR WHERE IT LIES ?>

Any help would be awesome! Thank you!

I don’t know what this is but it’s not valid syntax

[php]!regular expressions–preg_match($email)[/php]

I’m assuming you are trying to use the function there? I also don’t know what $postback is so I’m not sure if the condition is correct.

[php]
if ($postback && !fIsEmail($email)) {
echo “Please enter valid email.”;
$pageValid = false;
}
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service