redirect page with header function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ranjitbd
Forum Newbie
Posts: 24
Joined: Sun May 03, 2009 1:59 pm

redirect page with header function

Post by ranjitbd »

i have a feedback.php page with javascript validation..so no one can submit any empty feedback..but after send a feedback if i click on refresh button on browser menu it is submitted again..
i can avoid this by submitted the feedback and take the control to the different page with a flash message that ur feed back submitted successfully..
but question is that i want to stay same feedback.php page after submitted the feed back..and the refresh button will not send the feed back again and again

thanks in advance
User avatar
dheeraj
Forum Commoner
Posts: 40
Joined: Fri Feb 06, 2009 11:54 am

Re: redirect page with header function

Post by dheeraj »

it can be done by two ways :
1. using header function (php)
2. using window.location (java script)

1st one is

Code: Select all

 
<? . . . . . .
your code
. . . . . .
if(condition is true)
    header("Location: feedback.php");
?>
 
2nd one is using javascript

Code: Select all

 
<? . . . . . .
your code
. . . . . .
if(condition is true){
?>
<script type="text/javascript">
window.location="feedback.php";
</script>
<? }?>
 
ranjitbd
Forum Newbie
Posts: 24
Joined: Sun May 03, 2009 1:59 pm

Re: redirect page with header function

Post by ranjitbd »

dheeraj wrote:it can be done by two ways :
1. using header function (php)
2. using window.location (java script)

1st one is

Code: Select all

 
<? . . . . . .
your code
. . . . . .
if(condition is true)
    header("Location: feedback.php");
?>
 
2nd one is using javascript

Code: Select all

 
<? . . . . . .
your code
. . . . . .
if(condition is true){
?>
<script type="text/javascript">
window.location="feedback.php";
</script>
<? }?>
 
Post Reply