You need to put the id of each item inside form to indicate the item that will be deleted.
<?php
$all_favorites= unserialize($_COOKIE['favorites']);
echo '<table>';
foreach($all_favorites as $key => $value) {
echo '<tr>';
echo 'Post-ID = ' . $value . ' ';
?>
<form method="POST">
<input type="hidden" name="id" value="<?php echo $value; ?>">
<button type="submit" class="btn btn-default" name="delete">
<span class="glyphicon glyphicon-trash"></span>
</button>
</form><br>
<?php
echo '</tr>';
}
echo '</table>';
if (isset($_POST['delete'])){
$id = $_POST['id']; // do security checks (sanitize etc)
// unset post with $id from cookie
}
?>
Related Posts:
- How to include landing page with form submission?
- Gravity Forms skip form if already filled out using cookie?
- How to Collect Keyword and Search Engine Data on Webforms?
- What is & used for
- How to edit a user profile on the front end?
- Is wp_nonce_field vulnerable if you know the action name?
- Autocomplete for taxonomy input boxes on a front end form
- how to handle forms in multiple pages?
- set_query_var doesn’t seem to work on init hook
- How to send multipart form data to WordPress endpoint
- Placeholders in Jetpack Contact Form [closed]
- $_POST empty on submit (same code, same form submits normally on local server)
- Loading scripts & styles from a meta box callback function
- One comment per user per post
- Looking for a simple approach for handling user $_POST data without AJAX?
- How to return variables from admin-post.php
- Setting specific image size for specific form upload file field
- Get data from dropdown and update page
- Return to option page after running PHP script
- Help with forms and nonces
- Stripe Error: must provide source or customer [closed]
- How to submit form in a PHP file in WordPress?
- How to prevent page from resubmit on refresh when “Cannot modify header information – headers” warning shows
- How to edit custom user meta information front end
- How to redirect new WordPress user to previous page after registering
- WPForm, how to set date to tomorrow
- php form create 2 posts
- Creating a contact form with Laravel frontend
- Using form parameters within a WordPress “Page”
- Contact Form 7 – Add a Info Text to Checkboxes/Radiobuttons [closed]
- Make a form that will send email to all the authors in selected category [closed]
- How to make WordPress forms secure (HTTPS)
- Can you have more than one nonce on a page?
- Can I make Contact Form 7 change over to a new page? [closed]
- Password protected page with a form submits for me fine but for others redirects them back to the password prompt
- How dynamically change wp_mail behaviour, sending html or plain text based on conditions?
- Remove field in the form : only works for “url”, not for “email”?
- Creating short code for search form
- How to add required fields in user profile admin page?
- Problem in getting Value through POST method after Login
- Java code/ JSP page in wordpress
- Downloadable content only for subscribers?
- how to add a custom form in a page
- Form Submission Warning: Cannot modify header error only when plugin is deactivated
- Create a registration form with a PayPal checkout fee? [closed]
- comment form name and email not working?
- Sort populated GravityForms list alphabetically [closed]
- form action wordpress and php
- Checkboxes in a wordpress form are not showing as checked when selected [closed]
- Radio&Checkbox buttons Contact form 7 not clickable
- Complex Timesheet Form
- WordPress Emails & Contact Forms [closed]
- How to add a placeholder to the protected post password input
- How to change a form end email?
- How to set cookies
- Saved emails at dashboard
- Fatal error: Call to undefined function wp_insert_post()
- Simple form validation for custom post type in front end. Not working
- WordPress Frontend Post Form (Bootstrap Modal) Not Creating Post
- Inquiry form like on URL [closed]
- Update user meta on custom wordpress form and redirect
- Headers already sent on a frontend post form using wp_redirect before get_header
- Contact form with Jquery and PHP don’t work
- Email from my theme’s contact form doesn’t get the reply-to address right
- Can I have two submit buttons in one form? [closed]
- how do i make the “contact us” on a page created not to display
- wordpress blog, is there a way to make anyone post in a blog without having login info
- Email form getting hacked
- sending form with time interval
- How to redirect a Link to a new tab in contact form 7?
- how do I hide or encrypt query strings for gravity forms
- Why is my contact form not working?
- Save and retrive data from a custom form to database
- WPAdverts – How to limit form submission 10 per month
- Using an iframe for a form help
- Trigger action when submitting form with WPForms [closed]
- Fatal Error with WP Forms
- How to call or add password input / generate password / password strenght meter in custom registration form?
- Need to show results on the frontend of an admin form
- Form data being sent to parent directory
- fetch custom post if meta key exist
- Passing form data on submit
- Trouble with checked() for array of multiple checkboxes
- Create a custom calculator in wordpress
- How to stopping auto scrolling after submitting the form?
- Preventing form resubmission on contact form plugin
- Plugin to get a result based on form checkbox
- How to handle dynamic form data with repeating fields?
- Pay before posting (frontend insert post)
- Passing input value into name of input
- wp_insert_post with POST data
- Adding a “Report the post” button/form?
- wordpress not saving form code in code editor
- Create register form plus send post
- Auto populate a Form
- Submit button returns to index page instead of sending data
- Order form for WP (similar to a wishlist) [closed]
- Is it possible to change the error message “This is a required field” for all checkout fields? [closed]
- How to reproduce the post format field in a front end form?
- How can I add email code authentication on form submission without any wp plugin?