Welcome to WebmasterWorld Guest from 54.147.134.218

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

php web form script stopped working

upgrade from 4.0.0 to 4.2.3

     
6:44 pm on Dec 31, 2002 (gmt 0)

New User

10+ Year Member

joined:Oct 29, 2002
posts:7
votes: 0


Hi -

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]

6:53 pm on Dec 31, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
posts:1782
votes: 0


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

6:53 pm on Dec 31, 2002 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 20, 2002
posts:61
votes: 0


You can try this thread:

[webmasterworld.com...]

It helped me a lot.

6:55 pm on Dec 31, 2002 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 20, 2002
posts:61
votes: 0


You beat me to it, Andreas! The link I sent has to do with the globals setting (my original problem...)

princess

6:58 pm on Dec 31, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
posts:1782
votes: 0


That is the problem here as well princess.

In PHP4.0 the register_globals was on, in PHP4.2 it is off.

Andreas

8:13 pm on Dec 31, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 28, 2002
posts:564
votes: 0


I've just installed a freeware mail script today: phpformmail.php.

Easy to configure, works like a dream. I love it!

4:05 pm on Jan 3, 2003 (gmt 0)

New User

10+ Year Member

joined:Oct 29, 2002
posts:7
votes: 0


Hi -
Thank you to everyone that replied, I appreciate it. Now on to try to implement a fix. :)
- wendi
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members