Jump to content

FILTER_VALIDATE_EMAIL not working


kn0wl3dg3

Recommended Posts

That's it. That's the whole script. I was just trying to get it to work; I had tried it once before and just wrote a regex instead when I got frustrated.

 

Maybe it's in my .ini settings?

 

It is?  Even without <?php tags?  How are you calling it?

Link to comment
Share on other sites

This is the entire thing:

 

<?php
echo 'Learning Email Filter<br />';


$email = "someone@exa mple.com";
echo $email; // to make sure it's being set

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "E-mail is not valid<br />";
} else {
echo "E-mail is valid<br />";
}

echo 'This will appear after the filter script if it works<br />';
?>

 

Maybe I'm not calling it correctly since you keep asking how I'm calling it. This was straight off the w3c site, so I wouldn't know if I was doing it wrong :)

Link to comment
Share on other sites

What I meant was are you calling it via terminal or browser?  Hmm, I copied your script exactly and it's working for me in the CLI and browser.  You may have a fatal error, try adding these 2 lines directly under your opening <?php tag:

ini_set ("display_errors", "1");
error_reporting(E_ALL);

 

Other than that there must be some environment setting that is affecting it.

Link to comment
Share on other sites

What I meant was are you calling it via terminal or browser?  Hmm, I copied your script exactly and it's working for me in the CLI and browser.  You may have a fatal error, try adding these 2 lines directly under your opening <?php tag:

ini_set ("display_errors", "1");
error_reporting(E_ALL);

 

Other than that there must be some environment setting that is affecting it.

 

This is what I get with errors on:

 

Fatal error: Call to undefined function filter_var() in /var/www/html/learning/email_filter.php on line 12

 

As to your other question, terminal or browser, I'm not sure what you mean, but i wrote it in a file and opened it in my browswer, so I'm assuming the answer is browser :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.