Jump to content

Header() Function Issues -- No redirect happening.


shanejeffery86

Recommended Posts

NOTE: The PHP code below is coming from the same index.php file that the 2nd header is redirecting too.

 

Hey all.

 

I have done a ton of research and troubleshooting on my end, so let me tell you first off what is not happening.

 

1.  There is nothing been echo'd prior to the header.

2.  The PHP tags have no space before/after them.

3.  The syntax for the header parameters are correct.

 

Here is the code block:

 

if($_POST['register'] == "Pay & Register"){
		include("../statreport/paid-content.php");

		$creatorID = findBoxCreatorID($_POST['box_id']);
		$creatorEmail = findCreatorEmail($creatorID);
		$returnURL = 'http://' . $_SERVER['SERVER_NAME'] . "/";

		$paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
		$payment_data = array(
			'cmd' => '_xclick',
			'business' => $creatorEmail,
			'item_name' => 'ContentBoxer Box Purchase - (User ID: ' . $user_id . ')',
			'item_number' => $_POST['box_id'],
			'amount' => 0.01, //$_POST['boxPrice'],
			'no_shipping' => 1,
			'return' => $returnURL,
			'shipping' => 0,
			'tax' => 0
		);

		$payment_data_2 = http_build_query($payment_data);

		header("Location: $paypal_url?$payment_data_2");
	}
	else {
		setcookie("ebook_uid",$user_id,mktime() + 31556926, "$box_path");
		setcookie("ebook_chk",$user_code,mktime() + 31556926, "$box_path");	

		//need to check that this still works...also, need to make it work when users log in and don't have basic required questions in their profile.
		if (!$displayallquestions)
		{
			header("location:index.php?e=".$_POST["box_id"]."&open=1"); //for 2-part registration, go to the next part.
		}
		else {
			$_POST["submit_questions"] = true; //for 1-part registration, set this so that we can move on to the custom questions.
		}
	}

 

Here is the thing though.  If the code executes down to header("location:index.php?e=".$_POST["box_id"]."&open=1");, this header runs perfectly fine.  However, if it tries to do the external header for the Paypal link, then nothing happens.  If I put in an echo right before the header redirect for Paypal, the echo gets run.  Also, if I take the output of the paypal URL and paste it into the URL bar, the URL works just as it is supposed to.  So, there is no issue with the paypal URL.  Something is going on with the header() function in regards to redirecting to an external site.

 

Any ideas?

 

As I think this may be mod_rewrite based, I am going to include the htaccess file as well.

 

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^contentboxer.com [nc]
rewriterule ^(.*)$ http://www.contentboxer.com/$1 [r=301,nc]
RewriteRule ^[0-9]+/group/([_A-Za-z0-9-]+)/box/([0-9]+)/? /shelf/index.php?s=$1&e=$2
RewriteRule ^[0-9]+/group/([_A-Za-z0-9-]+)/?$ /shelf/index.php?s=$1
RewriteRule ^[0-9]+/mp/([_A-Za-z0-9-]+)/box/([0-9]+)/? /mp/index.php?s=$1&e=$2
RewriteRule ^[0-9]+/embed/([_A-Za-z0-9-]+)/([0-9]+)/? /shelf/index.php?s=$1&e=$2
RewriteRule ^[0-9]+/embed/([_A-Za-z0-9-]+)/?$ /shelf/index.php?s=$1
RewriteRule ^[0-9]+/embed/([_A-Za-z0-9-]+)/([0-9]+)/params(.*)/? /shelf/index.php?s=$1&e=$2&param=$3
RewriteRule ^[0-9]+/embed/([_A-Za-z0-9-]+)/params(.*)/? /shelf/index.php?s=$1&param=$2
RewriteRule ^[0-9]+/([_A-Za-z0-9-]+)/([0-9]+)/? /shelf/index.php?s=$1&e=$2
RewriteRule ^[0-9]+/([_A-Za-z0-9-]+)/?$ /shelf/index.php?s=$1
RewriteRule ^rss/[0-9]+/?([_A-Za-z0-9-]?)/?([0-9]?)/?([_A-Za-z0-9-]?)/ /rss/rss.php

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.