Redirection

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
anniebelle82
Forum Newbie
Posts: 2
Joined: Mon Aug 20, 2007 3:18 am

Redirection

Post 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]
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post 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.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

The header function you have should redirect successfully. Are you getting an error or anything? What exactly isn't working?
Steve Mellor
Forum Commoner
Posts: 49
Joined: Thu Aug 02, 2007 8:18 am

Post 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.
Post Reply