I have this piece of coding, i am attempting to change the form action dynamically depending on a current selection on the form.
if a user selects 'paypal' I want the action to be set to <?php echo ci_site_url(); ?>corders/buy/<?php echo $order_id; ?> and something else if a user selects 'card'.
I have tried to set it using a variable '$post_order' but its not working.
How can i do this, i am a php newbie so this might be a stupid question to many? my code:
<div class="row ops-sm-10 mx-auto">
<form role=form action="<?php $post_order;?>" method="POST" id="PaymentMethodForm">
<label for="PaymentMethod">Choose a payment method:</label>
<select name="PaymentMethod" onchange="" id='PaymentMethod'>
<option value="">--Choose a payment method--</option>
<option value="card">card</option>
<option value="paypal">paypal</option>
</select>
<div>
<button type="submit">Safe Checkout</button>
</div>
</form>
<?php $selectedmethod = filter_input(INPUT_POST, 'PaymentMethod');?>
<?php if ($selectedmethod == 'paypal'): ?>
<?php $post_order = "<?php echo ci_site_url(); ?>corders/buy/<?php echo $order_id; ?>"
?>
<p>You selected Paypal </p>
<?php elseif ($selectedmethod == 'card'): ?>
<p>You selected card</p>
<?php endif ?>
</div>