I have a multi-page form that was created for me. All of the pages on the form have submit button that saves the data to a database, a previous button that goes to the previous page and a next button. The problem is that the data does not save if I click the previous or next links.
How can I set it up so that that submit button is automatically pressed before going to the previous or next page of the form?
<a class="form-buttons" href="<?php echo $prev_url;?>">Prev</a>
<div class="form-buttons-middle"><input type="submit" name="status" value="Save" /></div>
<a class="form-buttons" href="<?php echo $next_url;?>">Next</a>
I'm new to programming so any help would be greatly appreciated.
Thanks!
You can use three submit buttons and depending on which one was clicked you can run a certain code block..
Ie
<input type="submit" name="status" value="Prev" />
<input type="submit" name="status" value="Save" />
<input type="submit" name="status" value="Next" />
<?php
if(!empty($_REQUEST['status']) && $_REQUEST['status'] == 'Prev'){
//save data and redirect to previous page using header();
}
if(!empty($_REQUEST['status']) && $_REQUEST['status'] == 'Next'){
//save data and redirect to next page using header();
}
if(!empty($_REQUEST['status']) && $_REQUEST['status'] == 'Save'){
//save data and do whatever you want
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.