Need to migrate code from 4 to 5... help?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kevinguenther
Forum Newbie
Posts: 1
Joined: Wed Apr 16, 2008 3:37 pm

Need to migrate code from 4 to 5... help?

Post by kevinguenther »

I've been using a standard contact form for users to send email from for some time now but it's had some drawbacks. Partially because it requires register_globals to be set to "On" in the php.ini file (which I've been told can be a security concern) but primarily, because it doesn't work in PHP 5.

I'm in a situation now with a client where I need it to work in PHP 5. Since I'm such a hack with PHP, I'm hoping you on this forum can help.

Here's what's on the Contact page...
<!--Email Contact Form-->
<form action="sendeail.php" method="post" name="contact" style="margin: 16px;" onsubmit="return gonogo()">

<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />

<!--I've excluded the HTML details and am just showing the form tag, php info and submit button here-->

<p><input name="send" type="submit" class="boldtext" id="send" value="Send Email" style="margin-right:16px;" /></p>
</form>
And this is what's on the sendeail.php page
<!--Begin Feedback Messages-->

<p class="body">
<?php

//compare results
if ($html=="True"){
//If results was True, this is a valid user
print "<h1>Thank You!</h1><p>Your message has been sent.</p>";

$todayis = date("l, F j, Y, g:i a") ;

$subject = "Contact from Conquest website.";

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Message: $notes \n
From: $visitor ($visitormail) \n
Web: $visitorweb \n
Phone: $visitorphone \n
Fax: $visitorfax \n
Address: $visitorstreet \n
$visitorcity ($visitorprovince)\n
$visitorcountry ($visitorpc)\n

Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral: $httpref \n
";

$from = "From: $visitormail\r\n";

mail('contact@contactemail.com', $subject, $message, $from);

print "Message:</p><div style='border:1px solid #333; width:300px; height:100px; overflow:scroll;'>";
$notesout = str_replace("\r", "<br/>", $notes);
echo $notesout;
print "</div><p><a href='contact.php'>Send another message.</a></p>";
}

if ($html=="False"){
//the user is invalid
print "<h1>ERROR:</h1>Your message did not validate and was not sent.<br/><a href='contact.php'>Please go back</a> and enter the correct Validation Code.";
}
?>
</p>
Any ideas why this won't work in PHP 5?
Post Reply