Bueno, el tema es simple, lo que quiero es rellenar un formulario y enviarlo por página web... Tengo el código ya implementado en una página web y me funciona perfe, pero lo hice hace mucho y no me acuerdo bien, lo he implementado en mi página de ahora y no me funciona, no me sale nada simplemente... no sé en qué puede fallar... y he pensado... ahora mismo estoy trabajando desde localhost, php está activado correctamente y trabajo desde mac. Y no sé si esto influye, le que sea desde localhost y tenga que configurar o hacer algo más... o simplemente cuando lo suba a un servidor de internet me funcione bien y tal...
De todas formas os pego el código a ver si véis algo que falle...
Código HTML:
<form action="enviarMail.php" method="post" id="formulario"> <input type="hidden" name="post" value=" Enviar " /> <label for="author">Nombre:</label> <input type="text" id="author" name="author" class="required input_field" /> <div class="cleaner_h10"></div> <label for="email">E-Mail:</label> <input type="text" id="email" name="email" class="validate-email required input_field" /> <div class="cleaner_h10"></div> <label for="asunto">Asunto:</label> <input type="text" name="asunto" id="asunto" class="input_field" /> <div class="cleaner_h10"></div> <label for="text">Mensaje:</label> <textarea id="text" name="text" rows="6" cols="30" class="required"></textarea> <div class="cleaner_h10"></div> <input name="c" type="hidden" value="1"> <input style="font-weight: bold;" type="submit" class="submit_btn" name="enviar" id="enviar" value=" Enviar " onclick="enviarDatos(); return false;"/> <input style="font-weight: bold;" type="reset" class="submit_btn" name="reset" id="reset" value=" Limpiar " /> </form>
Código PHP:
<?
$m = $_GET['m'];
switch($m)
{
case 1: echo "E-mail enviado correctamente";
break;
case 2 : echo "Ha ocurrido un error. Por favor intentelo de nuevo más tarde.";
break;
}
echo "pepe";
?>
Código PHP:
<?php
$mail_destinatario = '[email protected]';
$asunto = $_POST['asunto'];
$nombre = $_POST['author'];
$email = $_POST['email'];
$mensaje = $_POST['text'];
$c = $_POST['c'];
$headers .= "From: ".$email. "rn";
if($c==1)
{
if(mail($mail_destinatario, $asunto, "Nombre: ".$nombre. "\nE-Mail: ".stripcslashes ($email)."\n Mensaje : ".stripcslashes ($mensaje), $headers))
{
header("Location: index.php?m=1#5");
}
else
{
header("Location: index.php?m=2#5");
}
}
?>