Hi Guys

I need a script which will allow me to redirect the user to an external webpage - I have a t&c's page on the site so the user needs to 'accept' t&c's before they are redirected to the thirdparty website.

I used javascript however it seems to not work very well it works every now and again which isnt good enough.

I am thinking of a php script which will allow me to do this

So my html has a checkbox and a submit button - what script would i put on the following page? i have named the tickbox 'terms' and the submit button 'submit' -

The script below seems to work on my test server however my client is using a drag and drop sort of program to build his website. His website seems to use frames / headers.

<?php 

$terms = $_POST['terms'];

if($terms == "terms") {
 header("Location: http://www.romancart.com/checkavailability.asp?storeid=43296");
} 

else {
 echo "please accept terms and conditions";
}

?>

The html code is

<form action="t&c.php"method="post">
	<p>	<FONT SIZE="-1" FACE="Verdana,Tahoma,Arial,Helvetica,Sans-serif,sans-serif">I agree to the Terms &amp; Conditions</FONT>
	  <input type="CHECKBOX" name="terms" value="terms">
	</p>
	<p><input type="SUBMIT" name="submit" value="Submit"></p>
</form>

As i say - there seems to be 2 different pages within the file structure - theres body_term_conditions.html and also header_terms_conditions.html

Any help would be great - please try keep it as simple as possible

Thank you

The code which is appearing on his site is

Warning: Cannot modify header information - headers already sent by (output started at /websites/123reg/LinuxPackage21/th/en/ew/thenewlyngarth.co.uk/public_html/html/t&c.php:2) in /websites/123reg/LinuxPackage21/th/en/ew/thenewlyngarth.co.uk/public_html/html/t&c.php on line 7

Do i take out the PHP bit or leave that in as shown above?

You just leave it there =)

The PHP tags must be opened and closed for the JavaScript, otherwise PHP won't interpret the <script> code. Like this:

<?php 

$terms = $_POST['terms'];

if($terms == "terms") 
{
    Redirect("http://www.romancart.com/checkavailability.asp?storeid=43296");
} 
else 
{
    echo "please accept terms and conditions";
}

// JAVASCRIPT REDIRECT FUNCTION
function Redirect($url) { ?>
	<script type="text/javascript">
		window.location = "<?php echo $url ?>"
	</script>
<?php 
}
?>

thanks for that guys but ive managed to get php code working which is

$terms = $_POST['terms'];

if($terms == "terms") {
 echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.romancart.com/checkavailability.asp?storeid=43296\">";
} else {
 echo "Please go back and accept the terms and conditions to carry on booking";
}

?>

im guessing the header script was conflicting with the header layout maybe - not sure

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.