Easiest way to give Javascript alert after PHP header() redirect -


i have page users submit form, , goes separate php script. after script done, header() redirects user page on. want if there error or conditions in script, redirect user same page display javascript alert once there warning message. append variables url , check $_get figure there easier way... perhaps post data, or that? thanks

if error encountered, store error state $_session array , redirect browser original page. have script on original page check if error state set. if yes, trigger javascript alert or whatever handling want have.

and @ common footer template (or @ footer of original page), check , clear errors array, doesn't persist when user moves other pages or reloads current page.

example:

processor.php

<?php if($something == $iswrong){     $_session['errors']['error5301'] = 1;     session_write_close();     header("location: http://www.example.com/originalpage.php");     exit; } ?> 

originalpage.php

<!-- header --> <?php if(isset($_session['errors']['error5301']) && $_session['errors']['error5301'] == 1){ ?>     <script type="text/javascript">         alert('something not correct!');     </script> <?php } ?>  <!-- page content --> .... ..... .. ......  <!-- footer --> <?php if(isset($_session['errors'])){     unset($_session['errors']); } ?> 

hope helps.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -