How to give new life into a five years old, simple but reliable PHP form?
- by Sam
Hi all. I have a script in php 5.2. I want to use a simple form. I found something a programmer made for me about 5 years ago. When I use it, PHP outputs an error now unless I set register_long_arrays = On, then it works fine.
On the PHP website, however, it says:
Warning This feature has been DEPRECATED as of PHP 5.3.0. Relying on this feature
is highly discouraged. It's recommended to turn them off, for performance reasons.
Instead, use the superglobal arrays, like $_GET.
Should I listen to PHP's warning, or just enable the option and keep using my old form happily? If the former, then how/where do I change this simple form, so it does not rely on the deprecated setting? Your answer is much appreciated.
form.htm
<html><body>
<form method="POST" action="form_sent.php">
...
</form>
</body></html>
form_sent.php
<html><body>
<?php
$email = $HTTP_POST_VARS[email];
$mailto = "[email protected]";
$mailsubj = "A Form was Sent from Website!";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list($key, $val) = each ($HTTP_POST_VARS)){$mailbody .= "$key : $val\n";}
if (!eregi("\n",$HTTP_POST_VARS[email])) {
mail($mailto, $mailsubj, $mailbody, $mailhead); }
?>
<b>Form Sent. Thank you.</b>
</body></html>