|
Posted by +RoZ on 05/25/05 03:08
Hi Peter. Thank you for your help.
I pasted here the old 4.01 transitional code.
hte xhtml new code I used is enctype="text/plain".
yet I receive the message that the form has been received by the
server, yet the email if without the fields filled by the user.
here's the code for the php forrm management.
## ALWAYS REMEMBER TO SET THESE TWO VALUES ##
$email_to = "info@mysite.com"; // indirizzo pinella
## $email_to = "me@mydomain.com"; // THE RECIPIENT EMAIL
$email_from = "info@mysite.com"; // THE "VIRTUAL" SENDER EMAIL
// the following is the original module page, to avoid spam
$pagina_del_modulo
="http://www.strombolialbergobrasile.it/stromboli_contatti.php";
// email_from is the address the email from your form will appear
originating from.
## DON'T EDIT PAST THIS POINT ##
// security informations gatering and elaboration
function GetIP()
{
if (getenv("HTTP_CLIENT_IP") &&
strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
$ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR") &&
strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR") &&
strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
$ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER['REMOTE_ADDR']) &&
$_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'],
"unknown"))
$ip = $_SERVER['REMOTE_ADDR'];
else
$ip = "unknown";
return($ip);
}/*-------GetIP()-------*/
// date e hour
$giorno = date("Y/m/d"); // year, month, day
$ora = date("h:i:s a"); // hour, minutes, seconds
// echo getip();
$origine = GetIP();
$message = "--------\n\n\n";
$message .="Computer name: " . getenv("REMOTE_HOST") . "\n"
. "IP address: " . getenv("REMOTE_ADDR") . "\n"
. "Port: " . getenv("REMOTE_PORT") . "\n"
. "User Agent: " . getenv("HTTP_USER_AGENT") . "\n"
. "Connection: " . getenv("HTTP_CONNECTION") . "\n";
$message .= "Data: " . $giorno . "ora: " . $ora . "\n";
$message .= "Origine: " . $origine . "\n";
$message .= "--------\n";
// end of security informations gatering and elaboration
// Form elaboration follows
if($field_required) {
$required = explode(",", $field_required);
}
$emailcontents = array();
while (list($key, $val) = @each($HTTP_POST_VARS)) {
$val = addslashes($val); $GLOBALS[$key] = $val;
if(!strstr($key,"field_")) {
if(count($required)) { if (in_array($key, $required) and !$val) {
error("$key"); }}
array_push($emailcontents,"$key:\t$val");
}
}
// title of the email in case it is not specified
if (!$field_you_subject) { $field_you_subject = "Email dal sito IP=" .
getenv("REMOTE_ADDR"); }
if (!$field_them_subject) { $field_them_subject = "Thank You"; }
$emailcontents = implode("\n",$emailcontents);
// aggiungo i dati sull'ip del mittente
$emailcontents .= "\n" . $message ."\n";
$eheader= "to_you_header.txt";
$ehandle = fopen ($eheader, "r");
$head = fread ($ehandle, filesize ($eheader));
fclose ($ehandle);
$efooter= "to_you_footer.txt";
$ehandle = fopen ($efooter, "r");
$foot = fread ($ehandle, filesize ($efooter));
fclose ($ehandle);
$emailcontents = $head . "\n" . $emailcontents . "\n\n" . $foot;
if ($email and $name) {
mail("$email_to","$field_you_subject","$emailcontents","From: $name
<$email>");
} elseif($email) {
mail("$email_to","$field_you_subject","$emailcontents","From:
$email");
} else {
mail("$email_to","$field_you_subject","$emailcontents","From:
$email_from");
}
//in thankyou XnameX will be replaced by your name
// Xremote_ipX will be replaced by the remote ip
$thanks= "thankyou.txt";
$thandle = fopen ($thanks, "r");
$thankyou = fread ($thandle, filesize ($thanks));
$thankyou = str_replace(XnameX, $name, $thankyou);
$thankyou = str_replace(Xremote_ipX , $name, $thankyou) ;
fclose ($thandle);
if($email and $field_no_thankyou != "1") {
mail("$email","$field_them_subject","$thankyou","From: $email_from");
}
$filename= "success.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XmessageX, $field_thankyou_message,
$contents);
print $contents;
fclose ($handle);
function error($field) {
$filename= "error.html";
$handle = fopen ($filename, "r");
$error = fread ($handle, filesize ($filename));
$error = str_replace(XfieldX, $field, $error);
print $error;
fclose ($handle);
exit();
}
I added to the original freeware code some instructions to retrieve
the ip of the sender, and the platform he is running (to optimize the
website dimensions, styles and features on a statistical basis).
thank you very much in advance for your help!
robert
On Tue, 24 May 2005 14:02:14 +0200, Peter Kühnlein
<p@uni-bielefeld.de> wrote:
>Hi Robert,
>
>the first thing that looks strange is that "text/plain" shows up in the
>code w/o "type=" and quotation marks. But it would be helpful to see a
>little more of your code anyway. How does the script receive the data in
>the variables? etc.
>
>Cheers,
>Peter
>
>+RoZ wrote:
>>
>> <form action="http://www.mysite/form%20xhtml.php?subject=mysubject""
>> method="post" name="contact_form" target="_self" id="form2"
>> text/plain>
>>
Navigation:
[Reply to this message]
|