MischaKemna wrote Then I would like the site to go to domain.com/rubbish. So basically each input should have it’s own result. It’s so a company can enter their company name and then the site shows a specific page for them. |
You can do that. I'm assuming the specific company pages are all housed on your website. See code below.
For testing make a page called adobe_dreamweaver.html (this is a company page - use underscores between words in a url, its good practice to do so) then use the below code for the search code.....this search code can go in any page you want. If a company name match is found the company page will open, if a match is not found an error page will appear, you will need to set a default error page up on you server, if there isnt already one.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Search company name</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
$('.search_company_name').css('cursor' , 'pointer').click(function(){
let company_name = $('.company_name').val();
company_name = company_name.replace(/\s+/g, '_');
company_name = company_name.toLowerCase();
window.location = company_name + '.html';
});
});
</script>
</head>
<body>
<input type="text" class="company_name" placeholder="Company Name">
<input type="submit" name="submit" class="search_company_name" value="Search">
</body>
</html>