using post rather than url to delete a product

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
methos
Forum Newbie
Posts: 13
Joined: Sat Oct 21, 2006 8:31 am

using post rather than url to delete a product

Post by methos »

The following line deletes a product in my shopping cart by placing an action straight on the url of the cart. How could deleting a product be achieved without placing anything on the url ?

The line:

Code: Select all

<input type=\"hidden\" name=\"action\" value=\"submit\" /><a href=\"Cart.pfs?action=delete&id=$line_no\"><img src=\"./images/trashicon.gif\" width=\"16\" height=\"16\" alt=\"Remove $data[1] from Basket?\" /></a>
Last edited by methos on Sun Feb 25, 2007 3:16 pm, edited 2 times in total.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

By using POST as the method of the form
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

You made a mistake in your HTML. You have the form working as a POST one, which is good, but your "trash can" part is what I'm worried about.

If you want to use an image as a submit button, change the input's type. And you don't make links in your form with the <a> tag. You simpy make submit buttons and it'll be pointed at the place you put in the "action" attribute for your <form> tag.

I'd suggest you look at a few basic tutorials for working with forms and be sure to read everything explained carefully. If you want to go a step further, I'd even suggest reading a beginner book for PHP. They help explain a lot of the basics and it gives you a good foundation for self-learning online.
Post Reply