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

Add PHP Server Variables Like HTTP_REFERER to Your Form

(3172 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");
with:
// 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));
with:
//$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:
<html>
<head>
</head>
<body>
<a href="my_form.php">My Form</a>
</body>
</html>

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