Restricting a User to enter Valid Data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Kakumanuprince
Forum Newbie
Posts: 3
Joined: Sat Aug 12, 2006 1:20 am
Contact:

Restricting a User to enter Valid Data

Post by Kakumanuprince »

Hi,

Can you please help me on how to restrict a User to not allow him to enter a other Mail ID's in MSN Mail ID Text box

Thank You
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Please explain this a little better.
lohitha
Forum Newbie
Posts: 3
Joined: Mon Aug 14, 2006 12:58 am

Re: Restricting a User to enter Valid Data

Post by lohitha »

hi
Kakumanuprince wrote:Hi,

Can you please help me on how to restrict a User to not allow him to enter a other Mail ID's in MSN Mail ID Text box

Thank You
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

How exactly was that helpful? I asked for a better explanation, not a quote of the original post. Thanks.
Kakumanuprince
Forum Newbie
Posts: 3
Joined: Sat Aug 12, 2006 1:20 am
Contact:

Restricting a User to enter valid Data

Post by Kakumanuprince »

Everah wrote:Please explain this a little better.
Hi,

Thank You for your concern

As You might have seen in the Registration form of this very same forum We have two fields "MSN Messenger" and "Yahoo Messenger" and these fields accept any Mail ID as valid data for ex. if I enter my gmail Acc or Rediff acc. or Sify Acc. in this field, It is accepting as a valid mail ID. Can I restrict the User not to enter such ID's and make him only enter the Hotmail ID in "MSN Messenger" field and Yahoo ID in the "Yahoo Messenger" Field


Thank You
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Code: Select all

<?php
if ( !strstr($_POST['mail_id'], 'hotmail.com') )
{
    die('We cannot accept anything other than a hotmail.com email address');
}
?>
Where 'mail_id' is the field from your form.
lohitha
Forum Newbie
Posts: 3
Joined: Mon Aug 14, 2006 12:58 am

ANY INFO

Post by lohitha »

did u get any replies clarifying the doudt
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: ANY INFO

Post by RobertGonzalez »

lohitha wrote:did u get any replies clarifying the doudt
What? What does this mean?
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post by fastfingertips »

I suppose that you would like to force the user to enter same email ID in his contact and also in the MSN messenger field. In this case you should make a double validation, first one on the user side using JavaScript and the second one on server through PHP.

The php validation should look like:

Code: Select all

if(strcasecmp($_POST['user_email'],$_POST['user_email_msn']))
{
      //Error message here
}
Post Reply