Two submit buttons in one form::
Multiple Submit Buttons in a form-
We can use more than one submit button in a single form.
We can give each input a different value and keep the same name or different name:
#Same name Like::
<input type="submit" name="action" value="Update" />
<input type="submit" name="action" value="Delete" />
PHP Code:
if ($_POST['action'] == 'Update') {
//action for update here
} else if ($_POST['action'] == 'Delete') {
//action for delete
} else {
//invalid action!
}
#Diffent Name like::
<input type="submit" name="update_button" value="Update" />
<input type="submit" name="delete_button" value="Delete" />
PHP Code:
if (isset($_POST['update_button'])) {
//update action
} else if (isset($_POST['delete_button'])) {
//delete action
} else {
//no button pressed
}
Multiple Submit Buttons in a form-
We can use more than one submit button in a single form.
We can give each input a different value and keep the same name or different name:
#Same name Like::
<input type="submit" name="action" value="Update" />
<input type="submit" name="action" value="Delete" />
PHP Code:
if ($_POST['action'] == 'Update') {
//action for update here
} else if ($_POST['action'] == 'Delete') {
//action for delete
} else {
//invalid action!
}
#Diffent Name like::
<input type="submit" name="update_button" value="Update" />
<input type="submit" name="delete_button" value="Delete" />
PHP Code:
if (isset($_POST['update_button'])) {
//update action
} else if (isset($_POST['delete_button'])) {
//delete action
} else {
//no button pressed
}
No comments:
Post a Comment