1.11M Members

Checking if a button was pressed in previous page in

 
0
 

Hi , I am pretty new to php. I am making my first project that is a shopping website. Problem I face is in my view cart page. I have created only one page for viewing cart and adding a product to cart and then viewing it.
I mean I want my code to check if add to cart button was pressed in product.php then add insert and show otherwise just show table data. I am able to do these individually but not both at same time in same page. Is there a way or shall I create two different pages.

 
0
 

Your code for the add to cart would help, but in general (this is an example) if your button has name="add_to_cart", you just need to check it that data is posted:

if (isset($_POST['add_to_cart']) {
// Do what you need to do here
}
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: