473,799 Members | 3,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search Term Not Passing to Output Form

I have a search form from which I hope to be able to select a record by
field JobNumber and display it with an output form titled test.php

<html>
<head>
<title>Job Database Search</title>
</head>
<body style='font-family: Geneva, Arial, Helvetica, sans-serif;'>
Enter Job Number:
<form action="test.ph p" method="post">
<input type="text" name="searchter m">
<input type="submit" name="Send">
</form>
</body>
</html>

The query on the output form (test.php) is as follows and returns a blank
output:

$query="select * from jobs where JobNumber like '$searchterm'";

The problem I'm having is that the searchterm variable does not appear to
be passing to the output form. I know that I am connecting to the database
and that the query is fundamentally correct because I can access the record
I want by substituting a real Job Number for the variable.

Any ideas?
Jan 4 '06 #1
2 1332
"Bob Sanderson" <sa*****@LUVSPA Msandmansoftwar e.com> wrote in message
news:Xn******** *************** ***********@207 .69.189.191...
$query="select * from jobs where JobNumber like '$searchterm'";

The problem I'm having is that the searchterm variable does not appear to
be passing to the output form.


The first troubleshooting step anytime you are creating SQL strings
programmaticall y is to output the finished SQL string. This allows you to
spot unbalanced quotes, unanticipated whitespace, etc.

BTW, the example you give above is a classic "SQL injection" security flaw.
What happens if a malicious user enters a string into your input form such
as:

nomatch'; delete from jobs;

Another troubleshooting method is to cut & paste the finished $query string
into the mysql client (or MySQL Query Browser) and see if that statement
produces the query results you intend.

Also, make sure your PHP code tests for error status returned from the query
execution, and displays any error messages to the HTML output.

Regards,
Bill K.
Jan 4 '06 #2
On Wed, 04 Jan 2006 17:33:52 +0000, Bob Sanderson wrote:
The query on the output form (test.php) is as follows and returns a blank
output:

$query="select * from jobs where JobNumber like '$searchterm'";


First off, re-read Bill's advice even if you've already read it - it's
very important.

Do you have "register_globa ls" turned on?

It's not set by default on PHP now (and it's not a good idea either) so
you should be using the new superglobals:

$query="select * from jobs where JobNumber like '$_POST[searchterm]'";

Actually that isn't absolutely correct (as searchterm could be define()d
to be something else), but it's what 99.9% of PHP programmers use and is
fine as long as you are aware of defines.

Cheers,
Andy
--
Andy Jeffries | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Jan 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5021
by: leegold2 | last post by:
Commonly done, eg. you enter a word in a search engine and when a hit-page comes up the search word(s) are highlighted. I'm doing a fulltext search that works well but I've tried a few "packaged scripts" and haven't got one to work yet. I'm looking for straightforward understandable way to do this on my MYSQL/PHP pages. Thanks, Lee
4
2681
by: Ken Fine | last post by:
I'm looking to find or create an ASP script that will take a string, examine it for a search term, and if it finds the search term in the string, return the highlighted search term along with the words that surround it. In other words, I want the search term highlighted and shown in an excerpt of the context in which it appears. Any suggestions or pointers? This behavior is most often seen as part of a search engine. In my case, I want...
1
1640
by: Sheau Wei | last post by:
Below is my search engine code. I realize that the function was very limitied because i cannot searching the "NamaPealatan"(name of tools) compatible to the either categories Operasi or Balai or Komunikasi . If i want to add radio option in this code to minimize the area of searching, leet say at column Motor,(the option will be bermotor or Notmotor) how do i do? Below is my database CREATE TABLE `listofitem` `ID` INT( 10 ) NOT NULL...
3
2216
by: Sheau Wei | last post by:
This is the search engine code that i create, but it was error and didnt come out the result. Cn u help me to check what wrong with my code? Thanks <Table cellspacing=1 cellPadding=1 align=center> <td colspan=4> <h2 align=center>Bomba inventory searching system</h2> <tr> <td> <h4 Balai Bomba Inventory Searching System</H4> <form name="search" method="post" action="<?=$PHP_SELF?>">
1
2531
by: cglewis03 | last post by:
Hello, I am trying to build a search form with several different options to choose from. Currently it is set up to open within the same window if a single option is selected and open within a frameset if the "ALL" option is selected. Is there anyway to get the results to open in new windows? So if the user were to select the "ALL" option, is it possible to open 3 new windows with each result displaying? Here is my code:
10
2289
by: jonathan184 | last post by:
Hi I tried getting this to work through dreamweaver but it did not. So i found a n example on the internet , i followed everything exactly the search script does not work. Could somebody help me this please. Thanks for your help in advance. The form and script are on the same page. <?php require_once('../Connections/rs_ais.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
3
3971
by: suek | last post by:
I have a table with over 4000 records to search upon, and the users don't like a combo box. So what I have been trying to do for the last twelve hours is do some code to get a text box to search. I am learning fast, but I really don't know how to do it, and would appreciate some help. So far I have got to this: Private Sub btnSearch_Click() Dim strFindLocation As String
5
2767
by: reddem0n | last post by:
Hello, I've been working on trying to figure out how to script something where if a user enters more then one search term in the same fieldbox, it would query both of them and output it to a cf page. My scripting/issue is very similiar to an early thread by an individual here http://bytes.com/forum/thread655581.html Basically in my case....these are not words I am entering...I would be entering lets say 500-900 different email...
0
9687
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
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9073
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...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
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
4141
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
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
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.