Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 24th, 2007, 01:03 PM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to interpret checkboxes on server-side forms

Hi

I'm a beginer coder with javascript and PHP

I am coding a (very) basic online-store:

http://www.macs.hw.ac.uk/~avm1/Net&C...erch/shop.html

I am currently in the process of writing the PHP code to deal with the information on the form when it is submitted, and have hit a brick wall.

As you can see I only have three 'products' on this website. I am conciously not allowing the user to buy these products in varying quantities, rather forcing the user to select which products they would like via the checkboxes.

With the PHP code I am trying to design an order confirmation page, which will display the user's contact details and order details and ask them to confirm that they are correct.

I have got the textbox values working on the server side, but I am struggling with the checkboxes.

I want to be able to check which checkboxes are checked, and display the relevant product and price on the confirmation page.

For example, if the user submits the form with the Tshirt checkbox checked, I would like the PHP to return

Quote:
quote:Please confirm the following details are correct:

firstname surname
address
email address

Order:
Tshirt - £10
I cannot, however, figure out how to combine javascript and PHP in order to do this.

In searching, I have found similar example code, but it is much more complex than what I am trying to achieve and I cannot comprehend it.

Any help would be greatly appreciated guys

thanks in advance - Ravie

 
Old June 6th, 2007, 05:34 AM
Authorized User
 
Join Date: Mar 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pritz Send a message via Yahoo to pritz
Default

Hi ravie,

you can do one thing give the same name array something like product[] to all these product check box when you post your form in $_POSt you will be having this product[] which will save the values the one user had clicked.

ex:
<input type="checkbox" name="product[]" value="Tshirt-$10">Tshirt

hope this trick helps i have been to this problem once :-)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Converting Client-side to Server-side Code kwilliams ASP.NET 2.0 Professional 1 November 21st, 2007 05:25 PM
How to interpret checkboxes on server-side forms Ravie Javascript How-To 0 May 24th, 2007 01:10 PM
Checkboxes and continuous forms mdProgrammer Access VBA 4 August 3rd, 2006 09:47 AM
Firing server side events at client side codes mehdi62b ASP.NET 1.0 and 1.1 Basics 6 May 18th, 2005 09:11 AM
Accessing Server Side Data on Client Side steve456 Classic ASP Professional 3 October 15th, 2003 02:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.