<input type="text" class="form-control" placeholder="" id="sample" value="" name="sample" /> <title><?php echo $value ?></title>
so as I said before I'm trying to settle dynamic title for any page equal to search input value
Generally, a search query is a value set in the query-string of the current URL, such as:
/search?query=pizza
In PHP, you can access this via the $_GET superglobal:
$_GET
<?php echo $_GET['query']; ?>
If there isn't a query set, this on its own may lead to a warning/error, so you'll want to verify it's set first:
<title> Search <?php if (isset($_GET['query'])) { echo ' - ' . $_GET['query']; } ?> </title>
Warning: Make sure to always sanitize the output first though, otherwise you could introduce security vulnerabilities such as Cross-Site-Scripting (XSS). To sanitize, try htmlentities(), for example.
htmlentities()
<?php echo htmlentities($_GET['query']); ?>
Copyright © 2021 Jogjafile Inc.
Generally, a search query is a value set in the query-string of the current URL, such as:
In PHP, you can access this via the
$_GET
superglobal:If there isn't a query set, this on its own may lead to a warning/error, so you'll want to verify it's set first:
Warning: Make sure to always sanitize the output first though, otherwise you could introduce security vulnerabilities such as Cross-Site-Scripting (XSS). To sanitize, try
htmlentities()
, for example.