Jump to content

header help


toolman

Recommended Posts

Hi there,

 

I have a form which displays a "successful" message if the form is completed correctly. However, I want the form to go to another url if it is successful. I have tried this, but I get the "headers already sent..." message

 

// Add New Subscriber Success Message
$successMsg = header('Location: http://www.example.com/');

 

is there another way to forward onto another page?

 

Thanks

Link to comment
Share on other sites

Thanks for the reply.

 

Can anyone reccommend a way of forwarding the user to another page if the form is successful?

 

This is my code:

 

<?php if(isset($_GET['message']) && $_GET['message'] == 2):
			echo $successMsg;
	  elseif(isset($_GET['message']) && $_GET['message'] == 1):
	  		echo $errorMsg;
	  elseif(isset($_GET['message']) && $_GET['message'] == 4):
	  		echo $unsubscribeMsg;
	  elseif(isset($_GET['message']) && $_GET['message'] == 5):
	  		echo $failUnsubscribeMsg;
	  else:
?>

 

and

 

// Add New Subscriber Success Message
$successMsg = "<font color='green'>You have been successfully subscribed from the mailing list</font>";

Link to comment
Share on other sites

I am not sure what you mean if the form is succes, but you could check if the submit button is pressed and a certain form value is not empty. like this. I am using method post btw.

Place this before the <html> tag

 

<?php
$flag = false; // if flag is false show form.

if(isset($_POST['submit'])){//so if submit is pressed
    if ($message !== ' '){// message is not empty, you could add any additional if here btw. Just dont know how you form looks like
    echo "header('Location: http://www.example.com/')";
    $flag = true;// if flag is true dont show the form
}else{
    $flag = false;//if flag is false show it.
}
// dont forget to put  $flag in front of form
if ($flag=false){
echo 'put your form in here';
}

?>

 

Hope this is what your looking for.

ciao!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.