We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,167 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Checking if a button was pressed in previous page in

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.

2
Contributors
1
Reply
1 Hour
Discussion Span
5 Months Ago
Last Updated
2
Views
jasleen_kaur
Newbie Poster
9 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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
}
simplypixie
Practically a Master Poster
642 posts since Oct 2010
Reputation Points: 157
Solved Threads: 118
Skill Endorsements: 5

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0572 seconds using 2.69MB