Error 500 - Internal Server Error with php script

0

I have the following site where I have a form that sends the variables by post to% script in php where I have the function mail that sends these variables by mail : This is the form:

<form action="formulario.php" method="post">
  <div class="form-group">
    <input type="text" class="form-control" id="nombre" placeholder="Nombre" name="nombre">
  </div>
  <div class="form-group">
    <input type="text" class="form-control" id="nombre" placeholder="Apellido" name="apellido">
  </div>
  <div class="form-group">
    <input type="text" class="form-control" id="nombre" placeholder="Número Móvil" name="telefono">
  </div>
  <div class="form-group">
    <input type="mail" class="form-control" id="nombre" placeholder="Email" name="email">
  </div>

  <button type="submit" class="btn btn-ganarplata">QUIERO GANAR MÁS PLATA<br> VENDIENDO CLEAN WAY</button>
</form>

And this is the php script:

<?php
header('index.html');
$nombre = $_POST["nombre"];
$apellido = $_POST["apellido"];
$telefono = $_POST["telefono"];
$email = $_POST["email"];

// the message
$msg = "<html>
<head>
<title>Formulario Clean Way</title>
</head>
<body>
<p><b>Nombre:</b>
<br>
". $nombre ." 
</p>
<p><b>Apellido:</b>
<br>
". $apellido ." 
</p>
<p><b>Teléfono:</b>
<br>
". $telefono ." 
</p>
<p><b>Email:</b>
<br>
". $email ." 
</p>


</body>
</html>"
;
// More headers
$headers .= 'Content-Type: text/html' . "\r\n";;



// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// send email
mail("[email protected]","Formulario Contacto",$msg, $headers);
}
?>

By pressing the submit button, I receive a

  

Error 500 - Internal Server Error

What am I doing wrong?

I found an error, as they pointed out to me below:

At the beginning, the header function should go like this:

header ('Location: index.html');

Now my problem is that he still can not send the mail. What more do I need?

    
asked by Felipe Pino 12.11.2016 в 17:58
source

1 answer

0

The following line:

header('index.html'); 

generates an error, since it is not a valid HTML header .

Having no obvious function in the code, you should delete it.

For more information, read the PHP manual: header () .

    
answered by 13.11.2016 / 04:15
source