homepage Welcome to WebmasterWorld Guest from 54.166.113.249
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
php web form script stopped working
upgrade from 4.0.0 to 4.2.3
gibsonRB75

10+ Year Member



 
Msg#: 951 posted 6:44 pm on Dec 31, 2002 (gmt 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]

 

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 951 posted 6:53 pm on Dec 31, 2002 (gmt 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

princess

10+ Year Member



 
Msg#: 951 posted 6:53 pm on Dec 31, 2002 (gmt 0)

You can try this thread:

[webmasterworld.com...]

It helped me a lot.

princess

10+ Year Member



 
Msg#: 951 posted 6:55 pm on Dec 31, 2002 (gmt 0)

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

princess

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 951 posted 6:58 pm on Dec 31, 2002 (gmt 0)

That is the problem here as well princess.

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

Andreas

Longhaired Genius

10+ Year Member



 
Msg#: 951 posted 8:13 pm on Dec 31, 2002 (gmt 0)

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

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

gibsonRB75

10+ Year Member



 
Msg#: 951 posted 4:05 pm on Jan 3, 2003 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved