Page 1 of 1

Redirection

Posted: Wed Aug 29, 2007 10:05 pm
by anniebelle82
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi There,

Im currently writing some code that allows people to sign up for a newsletter, and get directed to another page. 

Im quite stuck, as my codes not working, and I really have no idea what to do (Im just a beginner).

Heres my code, most of it works fine, its the redirection that I cant get working.

Any suggestions?

Code: Select all

function curPageURL() {

 $pageURL = 'http';

 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}

 $pageURL .= "://";

 if ($_SERVER["SERVER_PORT"] != "80") {

  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];

 } else {

  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

 }

 return $pageURL;

}



if($_POST['action']=="news")

{

  $name = $_POST['name'];

							$email = $_POST['email'];

							$today = date("F j, Y, g:i a");

							$value = $_POST['send'];

							$link = curPageURL();
		

							$message = "

Newsletter Signup Received:

Date: $today

Name: $name

Email: $email

Page they signed up on: $link

							";
{
mail($_SESSION['ext'],$_SESSION['sitename'].' :: Newsletter Signup',$message,"From:".$_REQUEST['email']."\n"."Bcc:".$BCCMAIL."\n"."Content-type: text/html; charset=iso-8859-1\n"."X-Mailer: PHP 5.x");	
	

	}
	
header("Location:index.php"); 



}

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]1.[/b] Select the correct board for your query. Take some time to read the guidelines in the sticky topic.[/quote]

Posted: Thu Aug 30, 2007 8:17 am
by aceconcepts
Hi,

Why don't you try an html refresh?

Code: Select all

echo"<meta http-equiv=\"refresh\" content=\"0; url=someurl.com\">";
This refresh will redirect the user to the url shown in the refresh in 0 seconds.

It's nice and simple.

Posted: Thu Aug 30, 2007 9:00 am
by Begby
The header function you have should redirect successfully. Are you getting an error or anything? What exactly isn't working?

Posted: Thu Aug 30, 2007 10:33 am
by Steve Mellor
The header function might not work if you have already sent headers. In which case it should throw up an error. Where abouts does this code appear in your script?

If it's right at the top then you should be fine.