Here is my php:

<?php
$confirm = $_POST['confirm'];

if(($_POST['confirm'] == 'Y') {header("Location: http://mysite.com/sage/page1.php");}
else {header("Location: http://mysite.com/sage/disagree.html");}
?>

Here is the HTML:

<form id="form" action="terms_redirect.php" method="post">
	<table id = "radio">
		<tr>
			<td>
				<input type="radio" id="agree" name="confirm" value="Y" />
			</td>
			<td>
				<label for="agree">I have read and agree to the Terms and Conditions</label>
			</td>	
		</tr>		
		
		<tr> 
			<td>
				<input type="radio" id="disagree" name="confirm" value="N" />
			</td>
			<td>
				<label for="disagree">I disagree</label>
			</td>	
		</tr>		
		
		
	</table>
	
	<INPUT type="image" name="submit" id = "button" img src = "img/btn.gif" alt = "submit" />
		
</form>

This is the error I get:

Parse error: syntax error, unexpected '{' in /home/mysite.com/sage/terms_redirect.php on line 5

Can you see what's wrong with the code?
Thank you!

Try using this 'cleaner' code:

<?php

if(isset($_POST['confirm']) && $_POST['confirm']== 'Y'){
header("Location: http://mysite.com/sage/page1.php");
}
else {
header("Location: http://mysite.com/sage/disagree.html");
}
?>

I've thought about adding 'isset', but for some reason never did. :)
Anyway, what you've suggested - worked.
Thank you very much!

You're welcome;
I never understood why php loves isset that much. As time goes by, you start to blindly put it in!

You're welcome;
I never understood why php loves isset that much. As time goes by, you start to blindly put it in!

Yes, exactly. Logically, it shouldn't matter and is rather redundant in cases like this one.

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.