PHP Classes

Hidden Fields

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  PHP Forms Class with HTML Generator and JavaScript Validation package blog  >  How to Show Google Ma...  >  All threads  >  Hidden Fields  >  (Un) Subscribe thread alerts  
Subject:Hidden Fields
Summary:Want to have hidden fields show in 'FetchOutput'
Messages:4
Author:Lee Offenberger
Date:2008-01-16 21:53:01
Update:2008-01-17 00:05:55
 

  1. Hidden Fields   Reply   Report abuse  
Picture of Lee Offenberger Lee Offenberger - 2008-01-16 21:53:01
First, thank you for this class.

I have the class installed in a CMS to handle the forms. When a form is submitted, I'm grabbing the output of the form in HTML format using:

$message=$form->FetchOutput();

I then include the message in email that I send to others for processing.

In the form, I've created a hidden field to track the IP address of the post with:

$form->AddInput(array(
"TYPE"=>"hidden",
"NAME"=>"user_IP",
"VALUE"=>$_SERVER['REMOTE_ADDR'],
));

When I view the contents of $message, the "user_IP" is not included in the output.

Is there a way to force "hidden" types to show with FetchOutput()?

  2. Re: Hidden Fields   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-01-16 22:15:41 - In reply to message 1 from Lee Offenberger
You need to call AddInputPart somehow to add any input to the page.

Anyway, you should not be passing the user IP address through forms because any abuser may spoof that value.

  3. Re: Hidden Fields   Reply   Report abuse  
Picture of Lee Offenberger Lee Offenberger - 2008-01-16 22:39:55 - In reply to message 2 from Manuel Lemos
I've got an AddInputPart on the template page and it will not show up in the FetchOutput. It is in the $form object, because I can dump the variable and see "user_IP".

The issue is not the IP, it is the simple fact that I cannot get a hidden field to come through the FetchOutput even though I've got a matching AddInputPart in the template. I will not be using the IP address in the final deployment.

  4. Re: Hidden Fields   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-01-17 00:05:55 - In reply to message 3 from Lee Offenberger
You probably are making some mistake that prevents the input to show in the form output. It is hard to tell without seeing your code.

One thing that may help is to set the form object debug variable to "trigger_error" like you see in the class examples. That will make the class throw an error in a way that you may see in case there is some error.