Form action variable?
Posted: Thu Mar 25, 2010 3:17 am
Hello,
I have a form and I would like to set a variable for the action depending on users input. For instance;
Can anyone please help me along in the right direction?
I have a form and I would like to set a variable for the action depending on users input. For instance;
Code: Select all
<?php
if($_POST['first'] == '2')
{
$formaction = 'session2.php';
} else if($_POST['first'] == '3'){
$formaction = 'session3.php';
} else if($_POST['first'] == ''){
$formaction = 'session.php';
}
?>
<form action="<?php if(isset($_POST['first'])) echo $formaction; ?>" method="post">
<label>First Name:<input type="text" name="first" /></label>
<label>Last Name:<input type="text" name="last" /></label>
<input type="submit" name="poneSubmit" value="Continue" />
</form>