FORMfields, the premiere web framework
Support Home | Knowledge Base | Documentation | Forums | Contact Us
FORMfields & FORMgen :: Generated Forms

Add PHP Server Variables Like HTTP_REFERER to Your Form

(3262 views. Last Updated: 2007-08-13 2:12 PM)

Here is an example of how to add a PHP Server variable, like $_SERVER["HTTP_REFERER"] to your form and Control Panel.

1. Add a HiddenField to your form with Name: http_referer, Value: No Value, Max Length: 255

2. Edit your form and replace:
// Enter other default values here. Example: 
$ffForm->setValue("name", "John");
// Enter other default values here. Example: 
$ffForm->setValue("http_referer", FormField::getOrNull("HTTP_REFERER", $_SERVER));

3. Edit your Control Panel and replace:
$ffForm->addField(new HiddenField("http_referer", "No Value", 255, null));
//$ffForm->addField(new HiddenField("http_referer", "No Value", 255, null));
$ffForm->addField(new FormField("http_referer", "HTTP Referer"));

4. This step is only required because the the $_SERVER["HTTP_REFERER"] is only set after another page has referred to your form. This step is not needed for other PHP Server variables.
Create a referring page like index.php:
<a href="my_form.php">My Form</a>

5. Browse to index.php and click on the My Form link.
Support | Earn Money
Copyright © 2005-2020 Brain Book Software LLC.
Built with FORMfields, the premiere web framework.