sql server sql validate user login

Posted on 2009-04-15
Last Modified: 2012-05-06
I have a screen in front end where a User enters  Name
in the database table i just have firstname, lastname fields

The requirement is that in the the front end its just as  NAME  --  (Texbox) where in user can enter  
like  John Pat   or pat john Or just PAT  or just John. how can i write sql statement which validates the entry against firstname and lastname fields
Question by:dotnet0824
    1 Comment
    LVL 3

    Accepted Solution

    $name = $_POST['name'];

    $arr = array()
    $arr = explode(" ", $name);  //this will break the name up by spaces into an array

    //Then your SQL query - will check if either the first name or surname matches
    $query = "SELECT * FROM PEOPLE WHERE FNAME = ".$arr[0] ."OR FNAME = ". $arr[1] ." OR SNAME = ".$arr[0]." OR SNAME = ".$arr[1];


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (…
    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    746 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

    16 Experts available now in Live!

    Get 1:1 Help Now