Estimados, siendo este mi primer post, me anticipo con las disculpas si transgredo alguna norma--
Ahora el problema,
Recientemente cree un formulario de registro en php, con campos validados, el problema es que al registrarse, independiente de la direccion de correo que se incluya, el mensaje de inscripcion llega a la cuenta del admin y no llega ningún mensaje al que se registro
El detalle....
<?php
function ValidateEmail($email)
{
$pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
return preg_match($pattern, $email);
}
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
function WriteToFile($data)
{
$csvFile = "./formdata.csv";
$handle = fopen($csvFile, 'a') or die("can't open file");
$logtime = date("Y-m-d H:i:s,");
fwrite($handle, $logtime);
fwrite($handle, $_SERVER['REMOTE_ADDR']);
fwrite($handle, $data);
fclose($handle);
}
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$mailto = '[email protected]';
$mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
$subject = 'Inscripcion';
$message = 'Values submitted from web site form:';
$success_url = './gracias.html';
$error_url = '';
$error = '';
$autoresponder_from = 'Caceria del Zorro';
$autoresponder_subject = 'inscripcion';
$autoresponder_message = 'Su Inscripción ha sido recibida,
Muchas Gracias y feliz caceria
Atte.
El Zorro';
$eol = "\n";
$max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
$upload_folder = "upload";
$upload_folder = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])."/".$upload_folder;
$boundary = md5(uniqid(time()));
$header = 'From: '.$mailfrom.$eol;
$header .= 'Reply-To: '.$mailfrom.$eol;
$header .= 'MIME-Version: 1.0'.$eol;
$header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
$header .= 'X-Mailer: PHP v'.phpversion().$eol;
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address is invalid!\n<br>";
}
$prefix = rand(111111, 999999);
$i = 0;
while (list ($key, $val) = each ($_FILES))
{
if ($_FILES[$key]['name'] != "" and file_exists($_FILES[$key]['tmp_name']) and $_FILES[$key]['size'] > 0)
{
$upload_DstName[$i] = $prefix . "_" . str_replace(" ", "_", $_FILES[$key]['name']);
$upload_SrcName[$i] = $_FILES[$key]['name'];
$upload_Size[$i] = ($_FILES[$key]['size']);
$upload_Temp[$i] = ($_FILES[$key]['tmp_name']);
$upload_Type[$i] = ($_FILES[$key]['type']);
$upload_Link[$i] = "$upload_folder/$upload_DstName[$i]";
$upload_fieldname[$i] = $key;
$upload_fieldname_final[$i] = ucwords(str_replace("_", " ", $key));
$fieldvalue[$i] = $upload_Link[$i];
$i++;
}
if ($upload_Size[$i] >= $max_filesize)
{
$error .= "The size of $key (file: $upload_SrcName[$i]) is bigger than the allowed " . $max_filesize/1024 . " Kbytes!\n";
}
}
if (!empty($error))
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $error, $errorcode);
echo $errorcode;
exit;
}
$uploadfolder = basename($upload_folder);
for ($i = 0; $i < count($upload_DstName); $i++)
{
$uploadFile = $uploadfolder . "/" . $upload_DstName[$i];
if (!is_dir(dirname($uploadFile)))
{
RecursiveMkdir(dirname($uploadFile));
}
else
{
chmod(dirname($uploadFile), 0777);
}
move_uploaded_file($upload_Temp[$i] , $uploadFile);
chmod($uploadFile, 0644);
}
$internalfields = array ("submit", "reset", "send", "captcha_code");
$message .= $eol;
$message .= "IP Address : ";
$message .= $_SERVER['REMOTE_ADDR'];
$message .= $eol;
foreach ($_POST as $key => $value)
{
if (!in_array(strtolower($key), $internalfields))
{
$logdata .= ',';
if (!is_array($value))
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
$value = str_replace(",", " ", $value);
$logdata .= $value;
}
else
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
$logdata .= implode("|", $value);
}
}
}
$logdata = str_replace("\r", "", $logdata);
$logdata = str_replace("\n", " ", $logdata);
$logdata .= "\r\n";
WriteToFile($logdata);
if (count($upload_SrcName) > 0)
{
$message .= "\nThe following files have been uploaded:\n";
for ($i = 0; $i < count($upload_SrcName); $i++)
{
$message .= $upload_SrcName[$i] . ": " . $upload_Link[$i] . "\n";
}
}
$body = 'This is a multi-part message in MIME format.'.$eol.$eol;
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
$body .= 'Content-Transfer-Encoding: 8bit'.$eol;
$body .= $eol.stripslashes($message).$eol;
$body .= '--'.$boundary.'--'.$eol;
mail($mailto, $subject, $body, $header);
$autoresponder_header = 'From: '.$autoresponder_from.$eol;
$autoresponder_header .= 'Reply-To: '.$autoresponder_from.$eol;
$autoresponder_header .= 'MIME-Version: 1.0'.$eol;
$autoresponder_header .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
$autoresponder_header .= 'Content-Transfer-Encoding: 8bit'.$eol;
$autoresponder_header .= 'X-Mailer: PHP v'.phpversion().$eol;
mail($mailfrom, $autoresponder_subject, $autoresponder_message, $autoresponder_header);
header('Location: '.$success_url);
exit;
}
?>
<html>
(muy largo)
</html>
Muchas gracias amigos!!!! cualquier ayuda sirve