I am creating a search field for my website.
I have keywords for every “product” and I want to direct to their URL IF the entered value matches my keywords and ELSE redirect it to another page.
<form action="redirect.php" >
<input id="search" name="search" type="text" value="Search Here" />
<input name="submit" type="button" value="Go" />
</form>
The function I want :
<?php
if (isset($_GET['submit']));
$product1_keywords = "animal feeds, "weanrite, "Wean Rite;
$searchValue = $_POST['search'];
if ($search_fieldValue = $product1_keywords) {
header('Location: http://localhost/equalivet_2/#products/wean_rite.html');
}
else {
// Redirect page
header('Location: http://localhost/equalivet_2/not_found.html');
}
?>
Do I have to make a database to pre-define my keywords or a simple PHP will do?
Can anyone help me with this?
Your help will be very much appreciated. Thanks in advance!
Define an anchor tag in your html and your URL should point to the name of the anchor which is
yourpage.html#anchortagid
html
php
instead of using go to try redirect with the anchor in the end
that will automatically take you to a1 anchor