r-it Posted April 9, 2007 Share Posted April 9, 2007 I hope someone can help me with this dilemna, i have an activate form right, and i would like to redirect the user after they fill in the form and have no errors. that is not the problem as i can redirect, the problem is that i would like to have a javascript alert box telling the user that their account has been succesfully registered and then, in the background its redirecting to the index page. how would i send output to the server whilst redirecting at the same time?? Link to comment https://forums.phpfreaks.com/topic/46251-redirecting-and-javascript/ Share on other sites More sharing options...
neel_basu Posted April 9, 2007 Share Posted April 9, 2007 <meta http-equiv="refresh" content="4; url=http://url.com" /> Use this to Redirect It would 4 Secs and then redirect to http://url.com Link to comment https://forums.phpfreaks.com/topic/46251-redirecting-and-javascript/#findComment-224897 Share on other sites More sharing options...
Hughesy1986 Posted April 9, 2007 Share Posted April 9, 2007 Well if you want to use javascript with your php, its best to use Ajax. So you could show a prompt saying account created and then they click ok to continue, then in your javascript you can check if the value is true. If it is redirect them to your chosen page. Link to comment https://forums.phpfreaks.com/topic/46251-redirecting-and-javascript/#findComment-224905 Share on other sites More sharing options...
neel_basu Posted April 9, 2007 Share Posted April 9, 2007 Well if you want to use javascript with your php, its best to use Ajax. So you could show a prompt saying account created and then they click ok to continue, then in your javascript you can check if the value is true. If it is redirect them to your chosen page. But I dont think AJAX is required for this purpouse even JAvascript isn't required over. Technology is there but use it when you need it. Dont use it unnecesseryly.And You should not use Javascript here cause if the user disables javascript he wouldn't see any alerts. Use a HTML page to show user that he/ She have been Registered Successfully. Link to comment https://forums.phpfreaks.com/topic/46251-redirecting-and-javascript/#findComment-224907 Share on other sites More sharing options...
r-it Posted April 9, 2007 Author Share Posted April 9, 2007 the thing is, the page looks plain after that, i mean after the form has been successful, because it says you have been successfully registered, i also need this to work for when the user is updating his/her profile, so having an alert would be super as it will just need to redirect to the main page in the background and the user will know their status. something like this: <?php if($res) { //alert with javascript //redirect header("Location: index.php"); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/46251-redirecting-and-javascript/#findComment-224910 Share on other sites More sharing options...
neel_basu Posted April 9, 2007 Share Posted April 9, 2007 the thing is, the page looks plain after that, i mean after the form has been successful, because it says you have been successfully registered, i also need this to work for when the user is updating his/her profile, so having an alert would be super as it will just need to redirect to the main page in the background and the user will know their status. something like this: <?php if($res) { //alert with javascript //redirect header("Location: index.php"); exit; } ?> Although I'ven't Tested.This code would not work at all it would fire an error Header Already Sent Cannot Send Header Information again. Link to comment https://forums.phpfreaks.com/topic/46251-redirecting-and-javascript/#findComment-224919 Share on other sites More sharing options...
r-it Posted April 10, 2007 Author Share Posted April 10, 2007 I know that, thats why i want an alternative if there is, because the user has to know something before being redirected Link to comment https://forums.phpfreaks.com/topic/46251-redirecting-and-javascript/#findComment-225618 Share on other sites More sharing options...
neel_basu Posted April 10, 2007 Share Posted April 10, 2007 You dont need to use PHP header Redirection Rdirect Using Simple HTML Meta redirection <script> alert("Hi!"); </script> And then <meta http-equiv="refresh" content="4; url=http://url.com" /> Use this to Redirect It would 4 Secs and then redirect to http://url.com Link to comment https://forums.phpfreaks.com/topic/46251-redirecting-and-javascript/#findComment-225621 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.