PDA

View Full Version : Update my mailform to PHP4 or 5



dude9er
19 Mar 2006, 10:52 AM
I have a form on my flash website that needs to be upgraded to PHP4 or 5. I have no idea how this is done. Can anyone help me with this conversion if it's not too much to ask? Here is my present code.




<?php

$adminaddress = "klm@somewhere.com";
$siteaddress ="http://www.somewhere.com";
$sitename = "somewhere";

// Gets the date and time from your server
$date = date("m/d/Y H:i:s");

// Gets the IP Address
if ($REMOTE_ADDR == "") {
$ip = "no ip";
} else {
$ip = getHostByAddr($REMOTE_ADDR);
}

// Gets the POST Headers - the Flash variables
$action = $HTTP_POST_VARS['action'] ;
$email = $HTTP_POST_VARS['email'] ;
$name = $HTTP_POST_VARS['name'] ;
$comments = $HTTP_POST_VARS['comments'] ;

//Process the form data!
// and send the information collected in the Flash form to Your nominated email address

if ($action == "send") {
$mRecipient = $adminaddress;
$mSubject = "Info Request";
$mBody = "A visitor at $sitename has left the following information\n
Name: $name
Email: $email\n
The visitor commented:
------------------------------
$comments

Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Time: $date";
$mHeaders = "MIME-Version: 1.0\n";
$mHeaders .= "From: $name <$email>\n";
mail($mRecipient, $mSubject, $mBody, $mHeaders);


//This sends a confirmation to your visitor
$mRecipient = $email;
$mSubject = "Thank You for visiting $sitename";
$mBody = "Hi $name,\n
Thank you for your interest in $sitename!
We will respond to your inquiry as soon as possible.\n
Cheers,
$sitename
$siteaddress";
$mHeaders = "MIME-Version: 1.0\n";
$mHeaders .= "From: $sitename <$adminaddress>\n"; // you can change $siteaddress to whatever address you wish if you expect reply to the confirmation email
mail($mRecipient, $mSubject, $mBody, $mHeaders);

$sendresult = "Thank you. You will receive a confirmation email shortly.";
$send_answer = '&answer=';
$send_answer .= rawurlencode($sendresult) . '&';
echo $send_answer;
}
?>

aaronabaci
20 Mar 2006, 10:53 AM
I have a form on my flash website that needs to be upgraded to PHP4 or 5. I have no idea how this is done. Can anyone help me with this conversion if it's not too much to ask? Here is my present code.


I think I did the code right... but I wonder what the last few lines were for.




<?php

$adminaddress = "klm@somewhere.com";
$siteaddress ="http://www.somewhere.com";
$sitename = "somewhere";

// Gets the date and time from your server
$date = date("m/d/Y H:i:s");

// Gets the IP Address
if ($_SERVER['REMOTE_ADDR'] == "") {
$ip = "no ip";
} else {
$ip = gethostbyaddr($_SERVER['REMOTE_ADDR']);
}

// Gets the POST Headers - the Flash variables
$action = $_POST['action'] ;
$email = $_POST['email'] ;
$name = $_POST['name'] ;
$comments = $_POST['comments'] ;

//Process the form data!
// and send the information collected in the Flash form to Your nominated email address

if ($action == "send") {
$mRecipient = $adminaddress;
$mSubject = "Info Request";
$mBody = "A visitor at $sitename has left the following information\n
Name: $name
Email: $email\n
The visitor commented:
------------------------------
$comments

Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: ".$_SERVER['REMOTE_ADDR']."
Date/Time: $date";
$mHeaders = "MIME-Version: 1.0\n";
$mHeaders .= "From: $name <$email>\n";
mail($mRecipient, $mSubject, $mBody, $mHeaders);

//This sends a confirmation to your visitor
$mRecipient = $email;
$mSubject = "Thank You for visiting $sitename";
$mBody = "Hi $name,\n
Thank you for your interest in $sitename!
We will respond to your inquiry as soon as possible.\n
Cheers,
$sitename
$siteaddress";
$mHeaders = "MIME-Version: 1.0\n";
$mHeaders .= "From: $sitename <$adminaddress>\n";
// you can change $siteaddress to whatever address you wish if you expect // reply to the confirmation email
mail($mRecipient, $mSubject, $mBody, $mHeaders);

$sendresult = "Thank you. You will receive a confirmation email shortly.";
$send_answer = '&answer=';
$send_answer .= rawurlencode($sendresult) . '&';
echo $send_answer;
}
?>


I hope that works well. If the post variables don't work, you could go back to $HTTP_POST_VARS if you want.