Os pongo en situación.
Tengo un formulario en la web reservas.php
Código HTML:
<form action="formulario.php" method="post" enctype="multipart/form-data" name="datos" id="datos"> <td width="24" height="370" background="Images/web_08.gif"> </td> <td height="370" colspan="2" align="center" valign="top"background="Images/web_09.gif"><div align="center"><BR> <table width="90%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <div align="justify" class="menus"> <DIV id="formulario"><span class="personas">Jose Alba </span><BR>657577117<br><br> <span class="personas">Cristian Blazquez </span><BR>609121700<br><br> La Curra, 46900 - Torrente<br>(Junto a Rte. La Curra)<BR> www.paintbaltorrentl.es<BR> <A href="mailto:[email protected]">[email protected]<br><br> </A> </DIV> </div> </td> </tr> </table> <span class="texto"><BR> </div> <table width="90%" height="40%" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="2"></td> </tr> <tr> <td width="68%" class="texto"><span class="menus">Nombre</span><br> <input name="nombre" type="text" class="casillas" size="20" maxlength="25" namesize="20">< /td> <td width="32%" rowspan="2" valign="bottom" class="texto"><img src="Images/enviar.gif" width="60" height="60" onClick="enviar()" style="cursor:pointer;"> </td> </tr> <tr> <td class="texto"><span class="menus">E-mail</span><br> <input name="email" type="text" class="casillas" id="email" size="20" maxlength="35" namesize="20"> </td> </tr> <tr> <td colspan="2" align="left" valign="middle" class="texto"><span class="menus">Comentario </span> <textarea name="comentario" cols="40" rows="4" class="casillas"></textarea> </td> </tr> <tr> <td colspan="2" align="left" valign="middle" class="texto"><?php include ("formulario.php");?></td> </tr> </table> </td> </form>
El formulario llama a formulario.php
Código PHP:
<?php
function check_email_address($email) {
if (!ereg("[^@]{1,64}@[^@]{1,255}", $email)) {
return false;
}
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^
_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false;
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
function lnonly($string) {
$eregi = eregi_replace("^([A-Za-z\Á\É\Í\Ó\Ú\Ñ\á\é\í\ó\ú\ñ\.]{1}[a-z\á\é\í\ó\ú\ñ\.]+(\ )*)+$","",$string);
if(empty($eregi)){
return true;
}
return false;
}
$nombre=$_POST['nombre'];
$email=$_POST['email'];
$comentario=$_POST['comentario'];
if (check_email_address($email)) {
if(lnonly($nombre)) {
if(($nombre != "") && ($email != "") && ($comentario != "")) {
$destinatario="[email protected]";
$fecha = date("d-M-y H:i");
$asunto="Formulario de contacto";
if ($_SERVER["HTTP_X_FORWARDED_FOR"] != "")
$ip.=$_SERVER["HTTP_X_FORWARDED_FOR"] . "\nIP Proxy: " . $_SERVER["REMOTE_ADDR"];
else
$ip.=$_SERVER["REMOTE_ADDR"];
$cabeceras.= "MIME-Version: 1.0\r\n";
$cabeceras.= "Content-type: text/html; charset=iso-8859-1\r\n";
$cabeceras.= "From: {$nombre} <{$email}>\r\n";
$cabeceras.= "Last-Modified: ".$fecha." GMT\r\n";
$cabeceras.= "Cache-Control: no-cache, must-revalidate\r\n";
$cabeceras.= "Pragma: no-cache\r\n";
$cabeceras.= "Reply-To: {$email}\r\n";
$cabeceras.= "CC:[email protected]\r\n";
$headers.= "MIME-Version: 1.0\r\n";
$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers.= "From: Servicio de contacto Paintball Torrent <{$destinatario}>\r\n";
$headers.= "Last-Modified: ".$fecha." GMT\r\n";
$headers.= "Cache-Control: no-cache, must-revalidate\r\n";
$headers.= "Pragma: no-cache\r\n";
$headers.= "Reply-To: {$destinatario}\r\n";
$respuesta="respuesta";
$texto="hola";
if(mail($destinatario, $asunto, $texto,$cabeceras)){
mail($email, $asunto, $respuesta,$headers);
echo "Mail enviado correctamente.";
}else{
echo "Mail fallido.";
}
}else{
echo "Rellena los campos.";
}
}else{
echo "Inserta tu verdadero nombre.";
}
}else{
echo "Inserta tu e-mail.";
}
?>
¿Que falla?
Muchas gracias.