Salve,
da quando il mio provider ha posto le register globals su off (per la questione della sicurezza), il form contatti che utilizzo non funge più.
mi hanno già spiegato che devo modificare la variabile in $_post['nomevariabile'] ma ho problemi sull'upload del file. devo sostituire $thefile con $_FILES['thefile']..ma non so dove!!!
vi prego aiutatemi :-(
questo è il codice in questione:
<?
function validate_upload($thefile) {
global $thefile_type, $thefile_name, $thefile_size;
$my_max_file_size = "102400"; # in bytes
$registered_types = array(
"application/msword" => ".doc",
"application/octet-stream" => ".doc"
); # these are only a few examples, you can find many more!
$allowed_types = array("application/msword", "application/octet-stream");
$start_error = "\n";
if ($thefile == "none") { # do we even have a file?
$error .= "\n- Nessun documento allegato.
";
} else { # check if we are allowed to upload this file_type
if ($thefile_size>$my_max_file_size) $error .= "\n- Il file allegato supera la dimensione massima consentita.
";
if (!in_array($thefile_type, $allowed_types)) {
$error .= "\n- Il file che hai inserito non è del tipo richiesto:
\n";
while ($type = current($allowed_types)) {
$error .= "\n" . $registered_types[$type] . " (" . $type . ")
";
next($allowed_types);
}
$error .= "\n";
}
if ($error) {
$error = $start_error . $error . "\n";
return $error;
} else {
return false;
}
}
} # END validate_upload
?>
<?
if ($_POST['op']=="invio") {
$error=0;
$msg="";
if ($_POST['nome']=="") {
$error=1;
$msg.="- Il campo nome è vuoto.
";
}
if ($_POST['cognome']=="") {
$error=1;
$msg.="- Il campo cognome è vuoto.
";
}
if ($_POST['email']=="") {
$error=1;
$msg.="- Il campo email è vuoto.
";
}
if ($_POST['email']!="" && !eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$",$_POST['email'])) {
$error=1;
$msg.="- L'email inserita non è valida.
";
}
if ($_POST['citta']=="") {
$error=1;
$msg.="- Il campo citta è vuoto.
";
}
if ($_POST['provincia']=="") {
$error=1;
$msg.="- Il campo provincia è vuoto.
";
}
$error_file="";
if (!$thefile || $thefile=="none" || $thefile=="") {
$error=1;
$msg.="- Non hai inserito il curriculum.
";
} else $error_file = validate_upload($thefile);
if ($error==1 || $error_file!="") {
echo"
Attenzione! Si sono verificati i seguenti errori:
$msg
$error_file
<a href=\"javascript:history.back()\">Clicca qui</a> per reinserire i dati.";
} else {
$emailto="email@email.it";
$data=date("j/m/Y");
$ora=date("h:i:s");
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"XX-1234DED00099A\"\n";
$headers .= "Content-Transfer-Encoding: 7bit\n";
$headers .= "From: $email\n";
$messaggio="--XX-1234DED00099A\n";
$messaggio.="Content-Type: text/plain; charset=iso-8859-1\n";
$messaggio.="Content-Transfer-Encoding: 7bit\n\r";
$messaggio.="Curriculum inviato il $data alle $ora\n\r\nDati inseriti\n";
$messaggio.="Nome: $nome\n\rCognome: $cognome\n";
if ($telefono!="") $messaggio.="Telefono: $telefono\n";
$messaggio.="Email: $email\nCommento:\n$commento\n";
$oggetto_send="Invio Curriculum";
$messaggio.="--XX-1234DED00099A\n";
$messaggio.="Content-Type: application/octet-stream; name=\"curriculum.doc\"\n";
$messaggio.="Content-Transfer-Encoding: base64\n";
$messaggio.="Content-Description: \"Curriculum\"\n";
$messaggio.="Content-Disposition: attachment\n\r";
$fp=@fopen($thefile, "r");
if ($fp) {
$data = fread($fp, filesize($thefile));
}
$curr = base64_encode($data);
$messaggio .= "$curr\n\r--XX-1234DED00099A--\n";
if (!mail($emailto, $oggetto_send, $messaggio, $headers)) {
echo"
Attenzione.
Si sono verificati degli errori durante l'invio della Email.
Vi preghiamo di riprovare <a href=\"javascript: history.back()\">cliccando qui.</a>
Se l'errore persiste Vi invitamo a riprovare più tardi. Grazie.";
}
else {
$messaggio_risposta="Grazie per averci contattato.\n\rIl vostro curriculum è stato inoltrato al responsabile del personale.\n\r\n\rDati inseriti\n";
$messaggio_risposta.="Nome: $nome\n\rCognome: $cognome\n\r";
if ($telefono!="") $messaggio_risposta.="Telefono: $telefono\n\r";
$messaggio_risposta.="Commento:\n\r$commento\n\r\n \r";
$messaggio_risposta.="Distinti saluti \n\r";
$oggetto2="Curriculum inoltrato";
mail($email, $oggetto2, $messaggio_risposta,"From: webmaster <$emailto>");
echo "
Email inviata correttamente.
I dati inseriti sono i seguenti:
";
echo"Nome: $nome
Cognome: $cognome
";
if ($telefono!="") echo"Telefono: $telefono
";
echo"Email: $email
Commento: ".nl2br($commento)."
Grazie per averci contattato.";
}
}
} else {
?>
grazie tanteeeeeeeee