Answer the question
In order to leave comments, you need to log in
What can the dynamic CNC block?
Good day!
There is a website of the trading platform, so it has a search for goods.
The problem arose in the dynamic CNC, namely this search query: example.ru/search - /here what the user was looking for
On the test version, everything works fine, I created .htaccess, index. php, search.php and everything is transferred to the browser line
And everything is deleted on the site and remains: example.ru/search/ without additional. lines I did it
in the following way:
In the .htaccess file
RewriteEngine On
RewriteRule ^search/(.*)/?$ search.php?str=$1
Template (tpl) templates
are included in index.php There is a search form in main.tpl:
<form class="my-class" role="search" action="http://example.ru/search/" method="post">
<input type="text" name="str" placeholder="Поиск" value="">
<button type="submit">Поиск</button>
</form>
if (isset($_POST["str"])) {
setcookie("str", $_POST["str"], time() + 9999999);
$_COOKIE["str"] = $_POST["str"];
header("Location: " . $_POST["str"] . '/');
}
Answer the question
In order to leave comments, you need to log in
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// сюда-бы проверку через фильтра $_POST["str"] прогнать...
setcookie("str", $_POST["str"], time() + 9999999);
$_COOKIE["str"] = $_POST["str"];
header("Location:/" . $_POST["str"] . '/');
}
header('Content-type:text/html; charset=UTF-8');
ob_start();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question