Tje Posted July 16, 2014 Share Posted July 16, 2014 Hi, I'm trying to display a message first before redirect to other page, but my code just directly redirect the page without display the message.please help me. if($num_rows == 0) { echo '<script type="text/javascript">alert("Please Enter Correct Details!");</script>'; header ('Location :login.php'); } Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted July 16, 2014 Share Posted July 16, 2014 The Location header tells the browser to ignore the response body and immediately jump to the specified page. So, no, it doesn't work like that. You either need a meta element or a JavaScript-based redirect (which will obviously not work if JavaScript is turned off). However, the whole idea is very bad as explained by the W3C in the link. Automatic redirects are generally confusing and can come at an inconvient time. What if the user was just about to do something on the page? This is 90s technology, we don't do that anymore. Either leave out the message stuff and just do an immediate redirect or implement a proper Ajax UI which handles this in a user-friendly way (this won't be easy). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.