Hola buenas apaxito!!
Estos son los cambios que acabo de hacer... no se lo he echo bien como lo tengo ahora.
Código PHP:
Ver original<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
//First check that no field is empty and that all fields exist.
if(isset($_POST['name']) && !empty($_POST['name'])){
}
if(isset($_POST['email']) && !empty($_POST['email'])) {
}
if(isset($_POST['comment']) && !empty($_POST['comment'])){
}
/*
// Complete error variable if necessary.
/*
{
if ( empty($nombre) ) $error['nombre'] ='It is obligatory to enter a name';
if ( empty($email) ) $error['email'] ='It is obligatory to enter a email';
if ( empty($comentario) ) $error['comentario'] ='It is obligatory to enter a comment';
}
*/
// If you entered is that everything is done correctly
if($link) {
//echo "Connection completed successfully.";
} else {
header( 'Location:error.php');
}
// insert data in database.
$sql = "INSERT INTO sumit(name, email, comment)
VALUES('".$name."','".$email."','".$comment."',)";
if($name && $email && $comment) {
if($resultado){
mandaMail($name, $email, $comment);
header( 'Location:informe.php?registro=true'); }
}else{
header( 'Location:failed.php?registro=false');
}
}
function mandaMail ($name, $email, $comment){
# These data are to be seen in the mail
$cuerpo = "
name: ".$name."
email: ".$email."
comentario: ".$comment."";
# asunto del mensaje
if (mail($mail,"Oliver Arthur Webmaster",$cuerpo, "From: ".$name." <".$email.">")) $header .= "X-Mailer: PHP/" . phpversion() . " \r\n"; $header .= "Mime-Version: 1.0 \r\n";
$header .= 'Content-type: text/plain; charset=utf-8' . "\r\n";
mail($to,$subject,$message,$headers); }
?>