Jump to content

[SOLVED] sting comparison help


tbare

Recommended Posts

looking for the best way to compare a string, and if a sting != equal something, do something, else, go back and fix it.

 

basically, i'm setting up an e-mail script, and i want to make sure the e-mail address entered is a valid, and not the default "user@domain.com"

 

any ideas as to what the best way to do this would be?

Link to comment
Share on other sites

that worked...

 

now, what would (in your opinion) be the best way to check that the e-mail address is a valid one (containing a [blah]@[blah].[blah])?

 

sorry for the noobish questions here, but i'm trying to learn as i go here... (as we all are, i know.)

 

Thanks for the help

Link to comment
Share on other sites

That will match an email pattern. This is a regular expression- basically you can say a regular defines a "dictionary" containing all of the "words" that follow the given pattern, and then checks if your "word" (string) is in that dictionary. The syntax of regular expressions isn't so difficult, and it's a very powerful tool, you should try and learn regular expressions (or in short- regex). Google will provide you alot of information. After you learn about regular expressions, the info in the manual will be a very good reference:

http://www.php.net/manual/en/reference.pcre.pattern.syntax.php

 

Orio.

 

Link to comment
Share on other sites

A regex cannot 'validate' an email address. It is a glorified spell checker, and that's all. It can only see if all the right parts exist for it to be an email address. Using the REGEX provided, if I entered user@domain.com into your webform, it would be accepted, because it is in the right format for a email address. As long as you are aware of that...

 

So, a REGEX can only catch a horrendous typo, or a submission that doesn't even try to look like an email.

 

The only true validation is to send a 'challenge' email to the address they entered, and wait for them to respond to it.

 

PhREEEk

Link to comment
Share on other sites

yeah... understood... i have it right now that if they left either of the default values in for either their e-mail or the recipient e-mail, it won't go through, then used the REGEX after that to make sure that it's in the right format...

 

Thanks for the heads up, though...

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.