0

I need to create a form where you have two possible finishing pages dependent on the answers you give in the form.

For instance if you have the question:

Do you like sweets?

And have the two possible outcomes

Yes or No

The answer yes takes you to a yesilikesweets.php or if you answer no when you hit submit
it takes you to noihatesweets.php

Any help greatly received.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by cambraydesign
0
<?php
// one way 
if($_POST['sweets']){
	if($_POST['sweets'] == "yes"){
		header( 'Location: ../ilikesweets.php' )
		
	}ELSE{
		header( 'Location: ../idontlikesweets.php' )
		
	}
}

echo "<form method=\"post\" target=\"_self\" >
do you like sweets</br>
<select name='sweets' size=\"1\">
	<option></option>
	<option value=\"yes\">yes</option>
	<option value=\"no\">no</option>
</select>
<input type=\"submit\" />
</form>"

?>


<?php
// another way
if($_POST['sweets']){
	if($_POST['sweets'] == "yes"){
	include "ilikesweets.php";
		
	}ELSE{
	include "idontlikesweets.php";
		
	}
}ELSE{

echo "<form method=\"post\" target=\"_self\" >
do you like sweets</br>
<select name='sweets' size=\"1\">
	<option></option>
	<option value=\"yes\">yes</option>
	<option value=\"no\">no</option>
</select>
<input type=\"submit\" />
</form>"
}

?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.