stuck with building a cart area with php | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

stuck with building a cart area with php

https://code.sololearn.com/wUkx223K5dHj/#php I've this foreach loop that loops through an array containing data fetched from the database, and display it into bootstrap cards. I would like to make like so when you click on the submit button in the card, the data in this same card are sent to another page, where they can be used for displaying another group of cards. I was thinking about different ways to do it, but I still not able to make it work. I would like to have some suggest, not even the real code but just an idea on how to proceed. Thank you a lot.

25th May 2020, 1:00 PM
Francesco Paolini
Francesco Paolini - avatar
4 Answers
+ 1
Create an html form. Something like this <form action='newPage.php' method='POST'> <input type='hidden' name='data' value ='value'> </form> Replace the action value with the php page to handle the submit. You can access the inputs by using filter_input Like this $data = filter_input(INPUT_POST, 'data', FILTER_SANITIZE_STRING);
25th May 2020, 2:48 PM
Ore
Ore - avatar
+ 1
Francesco Paolini I am glad that my answer helped. However the hidden attribute is part of the HTML spec. It is not a PHP feature
25th May 2020, 5:03 PM
Ore
Ore - avatar
0
thank you it worked! I'm pretty new to php and didn't knew of the 'hidden' type
25th May 2020, 5:02 PM
Francesco Paolini
Francesco Paolini - avatar
0
Well true, i just didn't needed it before start diving into php i guess!
25th May 2020, 5:09 PM
Francesco Paolini
Francesco Paolini - avatar