• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

sql server sql validate user login

Hi,
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
0
dotnet0824
Asked:
dotnet0824
1 Solution
 
ChimerazaCommented:
$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];

Regards
Nick
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now