Web Dev Blog

Looking for help with WordPress, Apache, Vim, Web Security and more. Here are a few tips.

global.inc.php and pt_register from phpFormGenerator is broken and not working

There is a tool that used to come with the cpanel installation on some of the bigger hosts (hostgator, bluehost, etc…) call phpFormGenerator.  This tool would let you create forms in a GUI and then give you code to upload to your website.

Part of this code was a file called global.inc.php.  global.inc.php included code that read the session variables that were passed to the post.  At the time it was written PHP3 was in common use and a function called pt_register was included that made assigning the value from a form field to a variable a little easier (it was kind of clunky at that point).

Basically you would have something like

pt_register('POST','Foo');

This would assign the contents of form field Foo to a variable $Foo.  The way this was accomplished was inherently unsafe and has been removed completely from current versions of PHP (PHP5.5).

If you have moved a site to a server running php 5.5 that uses this code the forms will be broken.

Thankfully there is an easy fix.  Form field contents are now put into the $_POST variable.  This means you can replace the pt_register call with this

$Foo = $_POST['Foo'];

Exact same thing is accomplished, just replace the pt_register lines in any form php files and the forms will work again.

1 comment for “global.inc.php and pt_register from phpFormGenerator is broken and not working

Leave a Reply