spock9458 Posted September 21, 2009 Share Posted September 21, 2009 I am trying to get a simple search to work, using input from a form entry. I have found tutorials and here is my very basic first try: <form method="post" action="contact_search.php"> See if your name is listed as a Contact in our database: <br><br> Enter your full name and click the "Search" button:<br> <input type="text" name="search" size="50"><br> <br><input type="submit" value="Search"></input> </form> Anyway, the first line of "contact_search.php" says "if ($search) {..." and goes through the mysql query code after the bracket. The 'else' code is just an echo that says "The search string is empty..." When I try to do a search, that is what I get - the message saying my search string is empty. Obviously something is wrong with my code and the string is not getting assigned to "$search"... I'm sure it's something simple, but can someone help? Thanks Quote Link to comment Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 The tutorial you are working from seems to be old, and relies on globals being on several things; $search needs to be assigned (and validated) <?php $search = mysql_escape_string($_POST['search']); // assuming it is used in a database query another thing, you could post the rest of the code to make sure we are assuming correct Quote Link to comment Share on other sites More sharing options...
syed Posted September 21, 2009 Share Posted September 21, 2009 Use the get method for searches not post. Quote Link to comment Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 Use the get method for searches not post. For public searches, I agree. Makes it easy for bookmarking / crawling etc. Either way... with little/no code, our diagnosis will only be assumptive and limited. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.