Jump to content

Simple PHP4 to PHP5 Tweak?


boondog

Recommended Posts

Please have mercy on the complete newbie.

 

This form handler used to work, then my server guy upgraded to PHP5 and now it only does half the job:

 

$incoming_subject = "Online Offer from $VenueName for $r_Artist";

This doesn't return the venue name or the artist anymore.

 

And the autorespond email doesn't send at all.

 

Any help would be greatly appreciated.

Thanks.

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/184558-simple-php4-to-php5-tweak/
Share on other sites

Wild guess, your old server settings had register_globals enabled. This automatically registers fields from a form as variables which is generally frowned upon because of security implications. To fix it you will have to manually set the variables using the $_POST (or $_GET) array. You could turn register_globals on in your settings if you have access, but as I said it's not recommended.

Probably the script relies on register globals being enabled.

Since using register globals is not safe and generally discouraged, you should use $_POST or $_GET array (depending on which method is being used by your form) to fetch this data.

See: http://www.php.net/manual/en/language.variables.superglobals.php

 

Probably the script relies on register globals being enabled.

Since using register globals is not safe and generally discouraged, you should use $_POST or $_GET array (depending on which method is being used by your form) to fetch this data.

See: http://www.php.net/manual/en/language.variables.superglobals.php

 

YIKES!  Thanks to you and cags for the lightning fast responses.

 

I don't know how to grab the variables via $_GET or $_POST.  Is this job something I need to hire someone online to do?  If so, who and how much should I have to pay them?  (Man, I hate being outside of my element like this.)

It's a modification you should be able to do yourself, it would take somebody that knows what they're doing a few minutes. Basically if your HTML looks something like this....

 

<form method="post">
<input type="text" name="surname" />
<input type="text name="firstname" />
</form>

 

With register_globals enabled PHP will automatically create the variables $surname and $firstname for you and store in them the values entered in the field. PHP also puts the variables in an array like so $_POST = array("surname"=>"value here", "firstname"=>"value here"); So basically everywhere in your script where you have $surname you need to substitute $_POST['surname'] instead. That's pretty much all there is to it (but note if you do just do a find/replace you could potential break the strings since "Online Offer from $_POST['VenueName'] for $_POST['r_Artist']" is invalid (enclosing the variable in {}'s would fix that.

It's a modification you should be able to do yourself, it would take somebody that knows what they're doing a few minutes. Basically if your HTML looks something like this....

(...)

So basically everywhere in your script where you have $surname you need to substitute $_POST['surname'] instead. That's pretty much all there is to it (but note if you do just do a find/replace you could potential break the strings since "Online Offer from $_POST['VenueName'] for $_POST['r_Artist']" is invalid (enclosing the variable in {}'s would fix that.

Aha, I get it.

So, in the code for the email subject, instead of

$_POST['VenueName']

I need to put

{$_POST['VenueName']}

 

... and the rest of the fix is to replace each $_FormVariableName with $_POST['FormVariableName']

 

By golly, I'll try it.

Thanks a heap.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.