I want to create 2 form submit, first button for save data, and the second button for backup. If i click 'Save Data' button, it's work, but if i click 'Save Data as Backup' it's not work.
How to save data as backup with this my code ?
<?=form_open('action/saveData')?>
<?=form_open('action/saveDataasBackup')?>
<label>Your Name</label>
<input type="text" name="name" placeholder="Your Name">
<input type="submit" value="Save Data">
<?=form_close();?>
<input type="submit" value="Save Data as Backup">
<?=form_close();?>
Thanks anyway
Forms can't be nested HTML5 working draft
I would suggest you to use a single form in this case. When you receive form at back end, you can check weather to save the data or to back it up. You can achieve such functionality by adding the name attribute. Your form be like this:
<?=form_open('action/saveData')?>
<label>Your Name</label>
<input type="text" name="name" placeholder="Your Name">
<input type="submit" name="save" value="Save Data">
<input type="submit" name="backup" value="Save Data as Backup">
<?=form_close();?>
In controller method you can check like this:
if(isset($_POST['save'])){
//perform save operation
}
if(isset($_POST['backup'])){
//perform backup operation
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With