Good day! There is a html form. It is necessary that after clicking on the button that sends the form, there is a redirect. those. The redirect should depend on what data the user enters (if the check returns true , then the user should be transferred to the page, say, auth.php . If false , the user should remain on the input page and get a warning window). I wonder how this can be done in php, and is it even possible to do this, since if we use header (), we will get an error.
1 answer
if we use header (), we will get an error
Well, correct this error and the whole business. Most likely, by the time you are trying to send a new header through the header, php has already sent part or all of the page to the browser. And headers as you know after sending the page can not be transferred. The easiest solution would be at the very top of the script, immediately after <? Php, insert the line ob_start (); And at the very bottom, before?>, Add echo ob_get_clean ();
- Accidentally found the solution even easier! <meta http-equiv = 'refresh' content = '0; url = index.php '> - ka5itoshka
- But your option is also suitable. - ka5itoshka
- oneThe meta tag is blocked by some browsers. Better on js: <script> document.location.href = 'index.php'; </ script> - atnartur
- Yes, I think it would be better, of course, on a frog, but if it is turned off by someone? - ka5itoshka
|