Forum Moderators: coopster

Message Too Old, No Replies

Conditional redirect with php

Redirecting to different sites

         

CoolBuddy

8:56 pm on Apr 8, 2009 (gmt 0)

10+ Year Member



Since asp page does not work on Linux server, I am trying to do it with PHP.

When the submit button is clicked from any one site, the data is submitted to a CRM and it should redirect to the appropriate site. The CRM has the redirect page link which will be used after storing the data.

How do I pass the button name to this php page, since it's not called directly from the submit page?

if ($buttonHit == 'c4r')
{
header( "Location: $site1url" );
exit ;
}
else
{
header( "Location: $site2url" );
exit ;
}

Can someone help?

[edited by: CoolBuddy at 9:39 pm (utc) on April 8, 2009]

rocknbil

10:33 pm on Apr 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard CoolBuddy, what variables are available? Find out by

header("content-type:text/html\n\n");

var_dump($_POST);

Or, if it's not post, use $_GET. You can use $_REQUEST which will print out either, but IMO it's important to use one or the other so you know what your program will expect.

If your script is not working, it's just in how the variable $buttonHit is being set.

CoolBuddy

5:22 pm on Apr 9, 2009 (gmt 0)

10+ Year Member



Thanks for your input. I tried a different method and it worked.

I set the cookie using javascript SetCookie("Button", "c4r"); with half a minute expiry.

Then used the php server side script to check the cookie.

if ($_COOKIE["Button"] == "c4r")
{
header( "Location: $site1url" );
exit ;
}
else
{
header( "Location: $site2url" );
exit ;
}

This works.