G
G
Genri_Rus2019-02-11 18:11:41
PHP
Genri_Rus, 2019-02-11 18:11:41

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>

And in search.php here:
if (isset($_POST["str"])) { 
  setcookie("str", $_POST["str"], time() + 9999999); 
  $_COOKIE["str"] = $_POST["str"];
  header("Location: " . $_POST["str"] . '/');
}

That's how everything works fine and the redirect works fine on the test version, but there is no such option on the site itself
.
Can there be some kind of php function for clearing flashes, or is it still an error in ob_start();, just a lot of them in the code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Volkov, 2019-02-11
@AronTito

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        // сюда-бы проверку через фильтра $_POST["str"] прогнать...
        setcookie("str", $_POST["str"], time() + 9999999);
        $_COOKIE["str"] = $_POST["str"];
        header("Location:/" . $_POST["str"] . '/');
}

And this is at the top of the code
header('Content-type:text/html; charset=UTF-8');
ob_start();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question