Jump to content


Photo

*SOLVED* Send data php4 to php5


  • Please log in to reply
2 replies to this topic

#1 Relevancy

Relevancy
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 23 May 2006 - 05:27 PM

Ok I have several sites using this send data script, but a new site got put on a server that has php5 and now the script is not working. It sends blank emails and doesnt not include the field data from the form.

Here is the page with the form [a href=\"http://www.beyondfossilfuel.com/promote.html\" target=\"_blank\"]http://www.beyondfossilfuel.com/promote.html[/a]

Here is the php code for the send data script:

<?php

$contents = $HTTP_SERVER_VARS['REMOTE_ADDR'] . " just entered this data into the form: " . $HTTP_POST_VARS['pageName'] . "\n\n";

//get the contents of the form from a post
while(list($key, $value) = each($HTTP_POST_VARS))
{
    
    if($key == "sendto"){ 
        $sendto = $value;
    }
    elseif($key == "redirectpage"){ 
        $redirectpage = $value;
    }
    elseif($key == "subject"){ 
        $subject = $value;
    }
    else
    {
        $contents .= "$key \t = \t $value \n";
    }
}

//get the contents of a form from a get
while(list($key, $value) = each($HTTP_GET_VARS))
{
    if($key == "sendto"){ 
        $sendto = $value;
    }
    elseif($key == "redirectpage"){ 
        $redirectpage = $value;
    }
    elseif($key == "subject"){ 
        $subject = $value;
    }
    else
    {
        $contents .= "$key \t = \t $value \n";
    }
    
}

//attach footer message

$from_header = "From: Beyond Fossil Fuel";

if($contents != "")
{
   //send mail - $subject & $contents come from surfer input
   mail($sendto, $subject, $contents, $from_header);
   // redirect back to url visitor came from
   header("Location: $redirectpage");
}
  else
{
   print($contents);    
   print("<HTML><BODY>Error, no data was submitted!");
   print("</BODY></HTML>");
}

?>

What do I need to change? I am not a php programmer at all. help!
[a href="http://www.searchenginerelevancy.com/" target="_blank"]Search Engine Relevancy[/a]
[a href="http://www.onlinecomputertips.com/alltips.html" target="_blank"]Computer Help Tips[/a]

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 23 May 2006 - 05:37 PM

I believe your new site that has PHP5 has a setting called register_long_arrays turned off in the php.ini and so your $HTTP_*_VAR's are not being populated/recognised. In order for your script to work correctly take of the HTTP and _VAR bits in your variable names like so:
$HTTP_POST_VAR become $_POST
$HTTP_GET_VAR becomes $_GET
$HTTP_SERVER_VAR becomes $_SERVER

You should use the much new superglobal arrays instead, which $_POST, $_GET, $_COOKIE, $_SESSION, $_SERVER etc.

#3 Relevancy

Relevancy
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 23 May 2006 - 05:46 PM

Wonderful! I love you! Is that too much to say? jk

Thanks.. it worked great.
[a href="http://www.searchenginerelevancy.com/" target="_blank"]Search Engine Relevancy[/a]
[a href="http://www.onlinecomputertips.com/alltips.html" target="_blank"]Computer Help Tips[/a]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users