469,602 Members | 1,826 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Using SELECT statement from user input

I am new to PHP and MYSQL. I have a Database table with 4 field. FirstName, LastName, DateofBirth and MemberNumber. I would like to have a form where a user can fill in the FirstName, LastName and date of birth, and a select statement will return the membernumber bases on the user input.

This is how i would execute a script without user input. How do i change it to user input.
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT `MEMBERNO`
  2. FROM `table`
  3. WHERE `DATEOFBIRTH` = '1960-06-01'
  4. AND `FIRSTNAMES` LIKE CONVERT( _utf8 'Name'
  5. USING latin1 )
  6. COLLATE latin1_swedish_ci
  7. AND `SURNAME` LIKE CONVERT( _utf8 'Surname'
  8. USING latin1 )
  9. COLLATE latin1_swedish_ci
[Please use CODE tags when posting source code. Thanks! --pbmods]

Can Someone PLEASE HELP
Jul 3 '07 #1
4 2552
kovik
1,044 Expert 1GB
You'd use the input in the $_POST array.
Jul 3 '07 #2
You'd use the input in the $_POST array.
I am a ABSOLUTE NOVICE, can u please explain in more detail, and how to set up the form. THX in advance
Jul 3 '07 #3
kovik
1,044 Expert 1GB
You'd be better off on a tutorial. I haven't written any tutorials to this end because there are too many security topics that I'd end up confusing new programmers with.

Google the _POST array.
Jul 3 '07 #4
ak1dnar
1,584 Expert 1GB
I am new to PHP and MYSQL. I have a Database table with 4 field. FirstName, LastName, DateofBirth and MemberNumber. I would like to have a form where a user can fill in the FirstName, LastName and date of birth, and a select statement will return the membernumber bases on the user input.

This is how i would execute a script without user input. How do i change it to user input.
SELECT DISTINCT `MEMBERNO`
FROM `table`
WHERE `DATEOFBIRTH` = '1960-06-01'
AND `FIRSTNAMES` LIKE CONVERT( _utf8 'Name'
USING latin1 )
COLLATE latin1_swedish_ci
AND `SURNAME` LIKE CONVERT( _utf8 'Surname'
USING latin1 )
COLLATE latin1_swedish_ci


Can Someone PLEASE HELP
Create a HTML form to get the user inputs.
Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="firstname" value="">
  2. // Other Inputs Goes here 
  3.  
Submit this form(using GET/POST) to a .php script. and get the User Inputs,

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $first_name = htmlspecialchars($_POST['firstname']);
  3. // Like wise get the other inputs
  4. ?>
  5.  
See here for more details.Give it a try by your self.
Jul 3 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by hokieghal99 | last post: by
12 posts views Thread by Mark Constant | last post: by
7 posts views Thread by Serge Rielau | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.