Forum Moderators: coopster
I am new to PHP and have a simple web form that was sending data via email. The web server here was recently upgraded, including an upgrade from PHP 4.0.0 to 4.2.3. Since then script tells me that there is no data submitted.
Does anyone know if there is something new in 4.2.3 that could cause this problem?
Any help that can be offered is MUCH appreciated!
thank you -
- wa
Form example:
<form action="it_app.php" method="post">
<input type="hidden" name="formproc[email]" value="name@domain.com">
First name: <input type="text" name="formdata[firstname]"><br />
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</form>
Script is as follows:
<?php
$formresults = "";
/* convert the form data into a string */
if (isset($formdata)) {
foreach ($formdata as $key => $value) {
$formresults .= sprintf("$key: $value\n");
}
} else {
exit ("No form data to process.");
}
/* determine if this should be emailed or filed */
if (isset($formproc["email"])) {
// form data should be emailed
/* change to match what you want the default values to be */
$emfrm = "applicant";
$emsubj = "web develeopment position";
if (isset($formproc["subject"])) $emsubj = $formproc["subject"];
if (isset($formproc["from"])) $emfrm = $formproc["from"];
mail($formproc["email"],$emsubj,$formresults,"From: $emfrm") or
exit("Unable to email results");
} elseif (isset($formproc["file"])) {
// form data should be appended to a file
$fp = fopen($formproc["file"],"a") or exit("Unable to open " . $formproc
["file"]);
$fw = fwrite($fp,$formresults) or exit("Unable to write to " . $formproc
["file"]);
} else {
// neither were set, issue an error message.
exit ("You must specify a destination for the form data (either email or
file).");
}
/* now check for the success variable and if it's set, issue a header,
otherwise, issue a standard success message.
*/
if (isset($formproc["success"])) {
header("Location: " . $formproc["success"]);
} else {
header("Location: app_submitted.html");
}
exit;
?>
[edited by: jatar_k at 6:12 pm (utc) on Jan. 2, 2003]
[edit reason] removed specifics [/edit]
As shown, before PHP 4.2.0 the default value for register_globals was on. And, in PHP 3 it was always on. The PHP community is encouraging all to not rely on this directive as it's preferred to assume it's off and code accordingly.
[php.net...]
You should use PHP´s new suberglobals [php.net] to access submitted values.
Andreas