I am trying to create a registration website where the users chooses amongst three options on the first page and after selecting, can move onto the second page where it is displays different information depending on the option selected previously.
On Registration_1.php this is the code:
<?php
$clicked = $_POST["Next"];
if(isset($_POST['Reg_type']))
{
header('Location:Registration_2.php');
}
elseif(isset($_POST['Next']))
{
header('Location:Registration_1.php');
echo "Error! You must select an option!";
// display form again here
}
?>
<form name="frmtype" action="Registration_2.php" method="post" >
<input type="radio" name="Reg_type" value="1"/> Registering myself with credit card or bank account <br/>
<input type="radio" name="Reg_type" value="2"/> Registering multiple people using credit card or bank account <br/>
<input type="radio" name="Reg_type" value="3"/> Registering multiple people using a purchase order <br/>
<input type="submit" name="Next" value="Submit"/>
</form>
How can I redirect the user back to this page if they simply click submit without choosing an option and possible display a error message, and send them to page 2 if they choose an option? Thank you
Edit: Added if block, but still moved to next page regardless of selecting an option or not. Is the header() not the correct method to move to another page?
Documentation: $_POST variable