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.

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
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.