Jump to content

redirecting and javascript


r-it

Recommended Posts

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

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.

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.

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;
}
?>

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.