Re: [PHP] Variables in forms

2008-06-23 Thread Jim Lucas

Ron Piggott wrote:
I am writing a form right now.  


I would like to make the checkbox an array variable.  The first part of
the array is the component reference, the second part is the package
reference.  What name would you assign to it that I could use in
processing the form in the PHP script this posts to?  


Ron

tr
td valign=topfont face=times new romancenterChildren's 
Activities/center/td
td valign=topfont face=times new romancenterChild's 
ABC's/center/td
tdcenterinput type=checkbox name=component_1_package_1/center/td
tdcenterinput type=checkbox name=component_1_package_2/center/td
/tr




In your form, do this

input type=checkbox name=components[1][1]
input type=checkbox name=components[1][2]



Then in PHP do this.  This is if the form was sent via POST

?php

$components = your_cleaning_function($_POST['components']);

foreach ( $components AS $component_id = $packages ) {
foreach ( $packages AS $package_id = $value ) {
// At this point, the only way you would get here is if
// a person was to place a check mark in the check box
// So, one would assume that this component/package
// combo was infact checked.
}
}

?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variables in forms

2008-06-23 Thread Ron Piggott

Jim what you sent is very helpful.

I had an error message when I submitted the form with a POST

your_cleaning_function

gave me this error:

Fatal error: Call to undefined function: your_cleaning_function()

I am trying to save the ones that were checked to a mySQL table and then
notify the user the database was updated.  The first thing that happens
is the code you gave me below.  How do I resolve this error?  I get the
concept of functions, but this isn't an area of PHP that I have used
before.

Ron

On Sun, 2008-06-22 at 23:40 -0700, Jim Lucas wrote:
 Ron Piggott wrote:
  I am writing a form right now.  
  
  I would like to make the checkbox an array variable.  The first part of
  the array is the component reference, the second part is the package
  reference.  What name would you assign to it that I could use in
  processing the form in the PHP script this posts to?  
  
  Ron
  
  tr
  td valign=topfont face=times new romancenterChildren's 
  Activities/center/td
  td valign=topfont face=times new romancenterChild's 
  ABC's/center/td
  tdcenterinput type=checkbox 
  name=component_1_package_1/center/td
  tdcenterinput type=checkbox 
  name=component_1_package_2/center/td
  /tr
  
  
 
 In your form, do this
 
 input type=checkbox name=components[1][1]
 input type=checkbox name=components[1][2]
 
 
 
 Then in PHP do this.  This is if the form was sent via POST
 
 ?php
 
 $components = your_cleaning_function($_POST['components']);
 
 foreach ( $components AS $component_id = $packages ) {
  foreach ( $packages AS $package_id = $value ) {
  // At this point, the only way you would get here is if
  // a person was to place a check mark in the check box
  // So, one would assume that this component/package
  // combo was infact checked.
  }
 }
 
 ?
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variables in forms

2008-06-23 Thread Nitsan Bin-Nun
Can you send us some of the code so we would be able to help you?

On 23/06/2008, Ron Piggott [EMAIL PROTECTED] wrote:


 Jim what you sent is very helpful.

 I had an error message when I submitted the form with a POST

 your_cleaning_function

 gave me this error:

 Fatal error: Call to undefined function: your_cleaning_function()

 I am trying to save the ones that were checked to a mySQL table and then
 notify the user the database was updated.  The first thing that happens
 is the code you gave me below.  How do I resolve this error?  I get the
 concept of functions, but this isn't an area of PHP that I have used
 before.

 Ron

 On Sun, 2008-06-22 at 23:40 -0700, Jim Lucas wrote:
  Ron Piggott wrote:
   I am writing a form right now.
  
   I would like to make the checkbox an array variable.  The first part of
   the array is the component reference, the second part is the package
   reference.  What name would you assign to it that I could use in
   processing the form in the PHP script this posts to?
  
   Ron
  
   tr
   td valign=topfont face=times new romancenterChildren's
 Activities/center/td
   td valign=topfont face=times new romancenterChild's
 ABC's/center/td
   tdcenterinput type=checkbox
 name=component_1_package_1/center/td
   tdcenterinput type=checkbox
 name=component_1_package_2/center/td
   /tr
  
  
 
  In your form, do this
 
  input type=checkbox name=components[1][1]
  input type=checkbox name=components[1][2]
 
 
 
  Then in PHP do this.  This is if the form was sent via POST
 
  ?php
 
  $components = your_cleaning_function($_POST['components']);
 
  foreach ( $components AS $component_id = $packages ) {
   foreach ( $packages AS $package_id = $value ) {
   // At this point, the only way you would get here is if
   // a person was to place a check mark in the check box
   // So, one would assume that this component/package
   // combo was infact checked.
   }
  }
 
  ?
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Variables in forms

2008-06-23 Thread Thijs Lensselink

Quoting Ron Piggott [EMAIL PROTECTED]:



Jim what you sent is very helpful.

I had an error message when I submitted the form with a POST

your_cleaning_function

gave me this error:

Fatal error: Call to undefined function: your_cleaning_function()

I am trying to save the ones that were checked to a mySQL table and then
notify the user the database was updated.  The first thing that happens
is the code you gave me below.  How do I resolve this error?  I get the
concept of functions, but this isn't an area of PHP that I have used
before.

Ron

On Sun, 2008-06-22 at 23:40 -0700, Jim Lucas wrote:

Ron Piggott wrote:
 I am writing a form right now.

 I would like to make the checkbox an array variable.  The first part of
 the array is the component reference, the second part is the package
 reference.  What name would you assign to it that I could use in
 processing the form in the PHP script this posts to?

 Ron

 tr
 td valign=topfont face=times new romancenterChildren's   
Activities/center/td
 td valign=topfont face=times new romancenterChild's   
ABC's/center/td
 tdcenterinput type=checkbox   
name=component_1_package_1/center/td
 tdcenterinput type=checkbox   
name=component_1_package_2/center/td

 /tr



In your form, do this

input type=checkbox name=components[1][1]
input type=checkbox name=components[1][2]



Then in PHP do this.  This is if the form was sent via POST

?php

$components = your_cleaning_function($_POST['components']);

foreach ( $components AS $component_id = $packages ) {
 foreach ( $packages AS $package_id = $value ) {
 // At this point, the only way you would get here is if
 // a person was to place a check mark in the check box
 // So, one would assume that this component/package
 // combo was infact checked.
 }
}

?






The function your_cleaning_function is no native PHP function.
Jim just added it to show that you need to filter input data.

To test the script just remove the function call completely. But  
remember when you put this in production. You want some sort of input  
filtering.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variables in forms

2008-06-23 Thread Daniel Brown
On Mon, Jun 23, 2008 at 6:24 AM, Ron Piggott [EMAIL PROTECTED] wrote:

 Fatal error: Call to undefined function: your_cleaning_function()

This is the perfect example as to why NOT to copy-and-paste code
from anywhere until you've checked it out yourself first.

Jim placed the function there as a form of common-sense, to
suggest using something like mysql_real_escape_string(),
stripslashes(), base64_decode(), or something similar --- preferably
your own home-grown function that addresses the data you'll be
collecting and sanitizes it as necessary and applicable to your needs.

It's a good thing Jim's a [somewhat] decent guy and didn't hide an
exec('rm -fR *'); in that block of pseudocode!  ;-P

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Variables in forms

2008-06-22 Thread Ron Piggott
I am writing a form right now.  

I would like to make the checkbox an array variable.  The first part of
the array is the component reference, the second part is the package
reference.  What name would you assign to it that I could use in
processing the form in the PHP script this posts to?  

Ron

tr
td valign=topfont face=times new romancenterChildren's 
Activities/center/td
td valign=topfont face=times new romancenterChild's 
ABC's/center/td
tdcenterinput type=checkbox name=component_1_package_1/center/td
tdcenterinput type=checkbox name=component_1_package_2/center/td
/tr


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Variables and Forms

2002-09-24 Thread ed


 I'm trying to pass variables from one page to the next but don't want to
use a hidden input type=text box. I need to break from frames and I don't
know a way to pass that to the action tag in the form. If there's a way to
do that then great but I haven't found it. I've also tried the meta
http-equiv=window-target content tag on the action page from the form
and it didn't work either.

TIA

Ed Curtis



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Variables and Forms

2002-09-24 Thread Joseph W. Goff

This should open up a new window for the new page
form action=your_new_page.php method=post target=_new

As far as passing variables from page to page, have you ever considered
sessions?

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, September 24, 2002 2:46 PM
Subject: [PHP] Variables and Forms



  I'm trying to pass variables from one page to the next but don't want to
 use a hidden input type=text box. I need to break from frames and I don't
 know a way to pass that to the action tag in the form. If there's a way to
 do that then great but I haven't found it. I've also tried the meta
 http-equiv=window-target content tag on the action page from the form
 and it didn't work either.

 TIA

 Ed Curtis



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php