salve a tutti,
ho un problema, ho un form scovato in rete tanto tempo fa e già applicato su un sito sempre su altervista, che messo in un nuovo sito sempre su altervista non funziona e viene letto come pagina html.
Il codice è identico, quindi non penso abbia problemi, ci sono magari da settare nel mio spazio opzioni od altro?
Posto comunque il codice. Grazie a chi può aiutarmi.
Codice PHP:
/*
############################ Contact Form ###########################
### |-----------------------------------------------------------| ###
### | WRITTEN 2005 by planetluc.com c/o Lukas Stalder | ###
### | THIS SMALL SCRIPT IS FREE AND MAY BE REDISTRIBUTED | ###
### |-----------------------------------------------------------| ###
#####################################################################
*/
/*
// ################ INSTALLATION #################
1. open the .php file where you want to have the contact form in.
2. paste this whole code in there
3. adapt values in the config section below to your needs.
4. upload the file - that's it!
// ############## END INSTALLATION ###############
*/
// ################### CONFIG ###################
// CSS classes e styles
$class_txt = "text";
$class_inputbutton = "inputButton";
$class_inputline = "inputLine";
$class_inputfield = "inputField";
$style_inputline = "width:355px;";
$style_inputfield = "width:355px;";
// email
$target_address = "miaemail@hotmail.com";
$email_subject = "Website Request";
// error messages
$err_name = "Inserire il nome/Please enter a name.";
$err_phone = "Inserire il numero di telefono/Please enter a phone number.";
$err_msg = "Inserire la richiesta/Please fill out the 'request' field.";
$err_email = "Inserire un indirizzo email valido/Please enter a valid email address.";
// misc text
$msg_date = "Date";
$msg_company = "Company";
$msg_name = "Name/Nome";
$msg_address = "Address/Indirizzo";
$msg_city = "Zip/City";
$msg_phone = "Phone/Telefono";
$msg_email = "Email";
$msg_answerby = "Reply by/Risposta tramite";
$txt_email = "Email";
$txt_phone = "Phone/Telefono";
$txt_post = "Post/lettera";
$txt_send = "Send";
$txt_mandatory = "Obbligatorio/Mandatory";
$msg_request = "Request/Richiesta";
$msg_indent = 11;
// messages
$txt_thankyou = "<div class='$class_txt'><h3>Grazie per averci contattato/Thank you for contacting us</h3>La tua richiesta è stata inviata, risponderemo il più presto possibile/Your request has been sent, we will respond as soon as possible</div>";
$txt_error = "<div style='color: #cc3300' class='$class_txt'><h3>Following errors occurred:</h3>{errors}</div>"; // {errors} is replaced by the errors that occurred
// ### GERMAN TRANSLATION ###
/*
$email_subject = "Anfrage an Dott.com";
// error messages
$err_name = "Bitte Namen angeben.";
$err_phone = "Bitte Telefon angeben.";
$err_msg = "Formulieren Sie bitte Ihr Anliegen.";
$err_email = "Geben Sie bitte eine gültige Email Adresse an.";
// misc text
$msg_date = "Datum";
$msg_company = "Firma";
$msg_name = "Name";
$msg_address = "Adresse";
$msg_city = "PLZ/Ort";
$msg_phone = "Fon";
$msg_email = "Email";
$msg_answerby = "Antwort per";
$txt_email = "Email";
$txt_phone = "Telefon";
$txt_post = "Post";
$txt_send = "Abschicken";
$txt_mandatory = "Pflichtfeld";
$msg_request = "Anfrage";
// messages
$txt_thankyou = "<div class='$class_txt'><h2>Danke für Ihr Interesse!</h2>Ihre Anfrage wurde verschickt und Sie werden baldmöglichst kontaktiert werden.</div>";
$txt_error = "<div style='color: #cc3300' class='$class_txt'><h2>Bitte beachten Sie folgendes:</h2>{errors}</div>"; // {errors} is replaced by the errors that occurred
*/
// ################ END CONFIG #################
function spaces($num, $fill=" "){
$foo="";
for ($i=0; $i<$num; $i++) $foo.=$fill;
return $foo;
}
function isValidEmail($addr){
if(eregi("^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\\.[a-z]{2,4}$", $addr))
return true;
else
return false;
}
// start form evaluation
$error="foo";
if ($_REQUEST['do']=="send"){
$error=false;
if ($_REQUEST['name']=="") $error.="» $err_name<br>";
if ($_REQUEST['fon']=="") $error.="» $err_phone<br>";
if ($_REQUEST['message']=="") $error.="» $err_msg<br>";
if (!isValidEmail($_REQUEST['email'])) $error.="» $err_email<br>";
if ($error===false){
$message="$msg_date:".spaces($msg_indent-strlen($msg_date)).date("d M Y, H:i", time());
if ($_REQUEST['firma']) $message.="\n$msg_company:".spaces($msg_indent-strlen($msg_company)).$_REQUEST['firma'];
if ($_REQUEST['name']) $message.="\n$msg_name:".spaces($msg_indent-strlen($msg_name)).$_REQUEST['name'];
if ($_REQUEST['adresse']) $message.="\n$msg_address:".spaces($msg_indent-strlen($msg_address)).$_REQUEST['adresse'];
if ($_REQUEST['ort']) $message.="\n$msg_city:".spaces($msg_indent-strlen($msg_city)).$_REQUEST['ort'];
if ($_REQUEST['fon']) $message.="\n$msg_phone:".spaces($msg_indent-strlen($msg_phone)).$_REQUEST['fon'];
$message.="\n$msg_email:".spaces($msg_indent-strlen($msg_email))."mailto:".$_REQUEST['email'];
$message.="\n\n".spaces(strlen("$msg_answerby ".$_REQUEST['kontakt'])+1, "=");
$message.="\n$msg_answerby ".$_REQUEST['kontakt']."!\n";
$message.=spaces(strlen("$msg_answerby ".$_REQUEST['kontakt'])+1, "=");
$message.="\n\n$msg_request:\n\n".$_REQUEST['message'];
mail($target_address, $email_subject, $message, "From: ".$_REQUEST['email']);
echo $txt_thankyou;
}else if ($error!==false) $error=str_replace("{errors}", $error, $txt_error);
}
if ($error!==false){
if($error!="foo") echo $error;
// form
echo "<script language='JavaScript' type='text/JavaScript'>\n";
echo "window.onload = function(){ document.form1.firma.focus(); }\n";
echo "</script>\n";
echo "<form name='form1' method='post' action=''>\n";
echo "<table border='0' cellpadding='1' cellspacing='0' class='txt'>\n";
echo "<tr><td> </td>\n";
echo "<td height='19'> </td></tr>\n";
echo "<tr><td width='75' class='$class_txt'>$msg_company</td>\n";
echo "<td height='19'><input name='firma' id='firma' type='text' class='$class_inputline' style='$style_inputline' value='".$_REQUEST['firma']."'>\n";
echo "</td></tr>\n";
echo "<tr><td width='75' class='$class_txt'>$msg_name*</td>\n";
echo "<td height='19'><input name='name' type='text' class='$class_inputline' style='$style_inputline' value='".$_REQUEST['name']."'>\n";
echo "</td></tr>\n";
echo "<tr><td width='75' class='$class_txt'>$msg_address</td>\n";
echo "<td height='19'><input name='adresse' type='text' class='$class_inputline' style='$style_inputline' value='".$_REQUEST['adresse']."'>\n";
echo "</td></tr>\n";
echo "<tr><td width='75' class='$class_txt'>$msg_city</td>\n";
echo "<td height='19'><input name='ort' type='text' class='$class_inputline' style='$style_inputline' value='".$_REQUEST['ort']."'>\n";
echo "</td></tr>\n";
echo "<tr><td width='75' class='$class_txt'>$msg_phone*</td>\n";
echo "<td height='19'><input name='fon' type='text' class='$class_inputline' style='$style_inputline' value='".$_REQUEST['fon']."'>\n";
echo "</td></tr>\n";
echo "<tr><td width='75' class='$class_txt'>$msg_email*</td>\n";
echo "<td height='19'><input name='email' type='text' class='$class_inputline' style='$style_inputline' value='".$_REQUEST['email']."'>\n";
echo "</td></tr>\n";
echo "<tr><td width='75' class='$class_txt'>$msg_answerby*</td>\n";
echo "<td height='19' class='$class_txt'><input name='kontakt' type='radio' value='$txt_email' checked> $txt_email \n";
echo "<input name='kontakt' type='radio' value='$txt_phone'> $txt_phone \n";
echo "<input name='kontakt' type='radio' value='$txt_post'> $txt_post\n";
echo "</td></tr>\n";
echo "<tr><td width='75' class='$class_txt'>$msg_request*</td>\n";
echo "<td height='19'><textarea name='message' cols='45'style='$style_inputfield' rows='10' class='$class_inputfield'>".$_REQUEST['message']."</textarea></td></tr>\n";
echo "<tr><td width='75' > </td>\n";
echo "<td height='19' align='right'>* $txt_mandatory</td></tr>\n";
echo "<tr><td width='75'> </td>\n";
echo "<td height='19'><input name='Submit' type='Submit' class='$class_inputbutton' value='$txt_send'>\n";
echo "<input name='do' type='hidden' id='do' value='send'></td>\n";
echo "</tr></table>\n";
echo "</form>\n";
}
/*
######################### END Contact Form ##########################
#####################################################################
*/
la pagina è www.ellevu.altervista.org/form.php
Grazie