Reputation: 69
For a games reservation system that I have created, I have made a search bar to allow for easier navigation of the games available. However, to make the system quicker to make a reservation, I would like to create a link to a form that would automatically post the details of the game into the reservation form, but I'm not sure how.
Here is the code I used to create the search bar, if needed.
$sql= "select * from games ";
if (isset($_POST['search_box'])) {
$search= mysql_real_escape_string( $_POST['search_box']);
$sql .= "WHERE GameName LIKE '%{$search}%' ";
$sql .= " OR GameDescription LIKE '%{$search}%'";
$sql .= " OR GameID LIKE '%{$search}%'";
}
$result = mysql_query($sql) or die(mysql_error());
After the PHP code, I used HTML, to create a search form:
<form name="search_form" method="POST" action="index.php">
Search: <input type="text" name="search_box" value="">
<input type="submit" name = "search" value = "Search">
</form>
Upvotes: 1
Views: 111
Reputation: 1213
You could pass the parameters in the url. For example, build a link like so:
<a href="/link-to-reservation-form?game=Zelda&sky=blue">Link to reservation form</a>
Then on your reservation form page, use php to check the query string for those parameters using $_GET['game']
(would return "Zelda") and $_GET['sky']
(would return "blue").
Upvotes: 2