This is a discussion on modifying a script that previously used register_globals within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I have this script that previously stayed on a server that had register_globals on. I've switched servers that ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi, I have this script that previously stayed on a server that had
register_globals on. I've switched servers that understandably has it off. I've read up on php.net and other variables like $_SERVER[], but I can't seem to modify it to a workable state. This form was used in conjunction with flash... any help would be greatly appreciated! <?php $adminaddress = "info@ZZZZZZ.com"; $siteaddress ="http://www. ZZZZZZ.com"; $sitename = "ZZZZZZ"; $date = date("m/d/Y H:i:s"); if ($REMOTE_ADDR == "") $ip = "no ip"; else $ip = getHostByAddr($REMOTE_ADDR); if ($action != ""): mail("$adminaddress","Form: $subject", "A visitor at $sitename has left the following information\n Name: $name Subject: $subject Email: $email Message: ------------------------------ $message Logged Info : ------------------------------ Using: $HTTP_USER_AGENT Hostname: $ip IP address: $REMOTE_ADDR Date/Time: $date","FROM:$adminaddress"); //confirmation email mail("$email","Thank You for visiting $sitename", "Hi $name,\n We should receive your message shortly. If we do not give a reasonable and timely response, please send an email to info@ ZZZZZZ.com \n Thank you for your interest in $sitename!\n Cheers, $sitename $siteaddress","FROM:$adminaddress"); //confirmation flash $sendresult = "Thank you for visiting. You should receive a confirmation email shortly. "; $send_answer = "answer="; $send_answer .= rawurlencode($sendresult); echo "$send_answer"; endif; ?> |
|
|||
|
echelon3@yahoo.com wrote:
> Hi, I have this script that previously stayed on a server that had > register_globals on. I've switched servers that understandably has it > off. > > I've read up on php.net and other variables like $_SERVER[], but I > can't seem to modify it to a workable state. This form was used in > conjunction with flash... any help would be greatly appreciated! One easy way is to add a few lines on top $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; and all the other vars $somavar = (isset($_POST['somevar'])) ? $_POST['somevar'] : $_GET['somevar']; |
|
|||
|
Arjen wrote:
> echelon3@yahoo.com wrote: >> Hi, I have this script that previously stayed on a server that had >> register_globals on. I've switched servers that understandably has it >> off. >> >> I've read up on php.net and other variables like $_SERVER[], but I >> can't seem to modify it to a workable state. This form was used in >> conjunction with flash... any help would be greatly appreciated! > > One easy way is to add a few lines on top > > $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; > > and all the other vars > > $somavar = (isset($_POST['somevar'])) ? $_POST['somevar'] : > $_GET['somevar']; Or, if you're lazy, which you shouldn't be: foreach($_POST as $key => $value){ $$key = $value; } (same can be applied to $_SERVER, $_GET etc.) Fast & dirty, with a lot more processing then necessary, but a quick solution when stressed for time, or to get things working again while working on a better solution. Assigning values one by one is safer, yet somewhat unnecessary too. Why not replace all your values like $REMOTE_ADDR with the likes of $_SERVER['REMOTE_ADDR']? It's somewhat more work, but a good editor (I like UltraEdit) can replace all occurances in different files of the variables with a few clicks. I've been told some editors can even list your used variables so you can quickly check wether you've missed one, but that's something I've never used. Grtz, Rik |
![]() |
| Thread Tools | |
| Display Modes | |
|
|