Page 1 of 1

using post rather than url to delete a product

Posted: Sat Jan 20, 2007 2:03 pm
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>

Posted: Sat Jan 20, 2007 2:17 pm
by matthijs
By using POST as the method of the form

Posted: Sat Jan 20, 2007 3:46 pm
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.