Jump to content

html search form for my php search script


Recommended Posts

i have just finished creating a search script

 

you can search for an entry inside the database by accessing search.php?query=YOURSEARCHHERE

 

but now i have a stupid question

 

how do i create the html form that will process the search?

 

basically i need to make a form with a text input and a send button

 

when send button is hit, the browser will go to the URL i mentionned above, where "YOURSEARCHHERE" is the words the user have entered inside of the text input

<html>
<!-- The form -->
<form name='form' action='redirect.php' method='post'>
<input type='text' name='query' /><br />
<input type='submit' name='submit' value='Search!' />
</form>
</html>

 

<?php

// redirect.php

$query = $_POST['query'];
header("Location: search.php?query=$query");
?>

 

*Not tested

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.