Cusotm error message for searchform

Question

On my site I have e search form wich looks like this:

<form action="index.php/search" method="POST">
        ...
</form>

And in search.php I am processing the user input and checking for errors.
Now if there is some kind of error I wand to redirect to my main page and display an error message under the search bar, indicating what was wrong with the userinput.
However, I am not shure how to do this. My idea was to use wp_redirect(home_url() ."?error=".$error);
in search.php and $error = $_GET['error']; on my main page to extract the GET variable form the URL. Howerver, this does not seem to work ($error never gets set).

Any suggestions what could be wrong with the existing code? Or is there a solution that is even better then what I am trying to do?

Edit:
If i change 'error' to 'mistake' the redirect does not even properly redirect to my main page.

0
Pepsilon7 2 months 0 Answers 11 views 0

Leave an answer