PHP validation (length check on email address and major)

Posted on 2006-06-03
Last Modified: 2012-05-05
Hi again!

I am sorry to ask you one more similar question to the one I asked before.

I have a script (as seen below) to validate name, major, GPA and email address.
I have no problem except on email. The problem with email address is that people can put a real lengthy (currently there is no limit) address which is most likely a bogus one.

I need your help to invalidate an email address which is abnormally too long (say, 60-characters).

The script to check the length of name worked fine. So I tried that to check the length of email, but it did not work.

Hope you may kindly help me out again!

Thanks again!


June 3, 2006, at 2:56 pm
Question by:duta
    LVL 49

    Accepted Solution

    You can use

    if(strlen($_POST['emailField']) > 80) {
      //fail email field


    Author Comment

    TO: Roonaan:

    Thank you so much for your kind, prompt response.

    Your tip worked just great.

    I am very honored to get help from a great master like you (your point: 939030). The number just testifies that you have helped a lot of  people.



    June 3, 2006, at 3:09 pm
    LVL 49

    Expert Comment

    Hi duta,

    Thanks for your kinds words. I didn't get that many points by being selective on who I help out. As all experts I try just to help out as much as I can. For php I have the privilige to be able to answer a lot of questions.


    Author Comment

    TO: Roonaan:

    Thank you so much for your kind response.
    I wish that someday I will be able to help others as you are doing so wonderfully and thoughtfully. Help is the best gift you can give a beginner like me.

    I have always thought that it is a great privilege to get help from a master like you at experts-exchange.

    God bless you!


    June 3, 2006, at 9:33 pm

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    A colleague recently asked me about how to give his client a small part of the web site that could be completely under the client's control.  Since I have done this sort of thing before to add emergency banners to a web site, I decided I would creat…
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now