473,608 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using SELECT statement from user input

4 New Member
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 2761
kovik
1,044 Recognized Expert Top Contributor
You'd use the input in the $_POST array.
Jul 3 '07 #2
bob1660
4 New Member
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 Recognized Expert Top Contributor
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 Recognized Expert Top Contributor
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

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

Similar topics

3
8796
by: hokieghal99 | last post by:
Hi, I'd like to get user input from an html form into a mysql select statement. Here's where I'm stumped: $result = mysql_query("SELECT * FROM dept WHERE notes LIKE '%search-string%'",$db); I need to get the user's input into the '%search-string%' section, but I do not understand how to do this. I can hard-code a specific search
3
2141
by: J. Muenchbourg | last post by:
I have an ASP admin script where I'm adding records, and I have a category that already has set name values hard-coded into a selct option pulldown, but if the user wants to create a new category and not use the select pulldown, the value will end up being " , newvalue" when posting from this sequence of pulldown and input text box: <select name="CategoryName"> <option selected></option> <option value="first">first category</option>...
0
6691
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
12
6065
by: Mark Constant | last post by:
I have a drop-down list now and I got it so when something is selected from the drop down list it calls a JavaScript function. I want it so the value selected from the drop-down list is sent as a parameter to the xslt file. When I select a value from the drop-down list nothing appears. I want just a basic listing of Title, Image, and Description outputed. I have done a basic JavaScript that uses the .write() function and that worked so the...
4
6455
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to define the servername / hostname in my Perl Progrem.. Here is the code:
0
2639
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how to call them from an ASP.Net page Every modern database system has a stored procedure language. SQL Server is no different and has a relatively sophisticated and easy to use system. This article will not attempt to go into depth in explaining...
7
6972
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get into the GUI because it is hard to describe in text. First of all what is the purpose of ALTOBJ()? This procedure was created mostly for ISVs who need to do produce change scripts to upgrade application from release to release, but it can also
8
2793
by: rbg | last post by:
I did use query plans to find out more. ( Please see the thread BELOW) I have a question on this, if someone can help me with that it will be great. In my SQL query that selects data from table, I have a where clause which states : where PermitID like @WorkType order by WorkStart DESC
0
7656
MMcCarthy
by: MMcCarthy | last post by:
Rather than using the Access design view change the view to SQL. I am going to attempt to outline the general syntax used for SQL queries in Access. Angle brackets <> are used in place of some syntax elements you must supply. The description of these elements will be in the contained in the angle brackets. Square brackets are used to show which parts are optional. Basic SELECT query SELECT <field list> FROM <table/query name(s)>
0
8057
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8491
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8470
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8329
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6813
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5475
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3959
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2472
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1327
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.