I have created a form with HTML and, subsequently, I have done the basic programming with PHP to send a message from a web page to an email. The code used is as follows.
Page.HTML
<form action="enviar.php" method="post">
<fieldset>
<legend>Contacta:</legend>
<ul>
<li>
<label for="nombre">Nombre:</label>
<input type="text" name="nombre" id="nombre" value="" />
</li>
<li>
<label for="apellidouno">Apellido:</label>
<input type="text" name="apellidouno" id="apellidouno"
value="" />
</li>
<li>
<label for="correo">Correo:</label>
<input type="text" name="correo" id="correo" value="" />
</li>
<li>
<label for="telefono">Teléfono:</label>
<input type="text" name="telefono" id="telefono" value="" />
</li>
</ul>
<p class="legend">Comentario:*</p>
<label for="comments"></label><textarea id="comments"
class="espectativas" name="comentario" cols="50" rows="7">
</textarea>
<input type="submit" value="Enviar" id="aceptar" />
<input type="reset" value="Borrar" id="borrar" />
</fieldset>
</form>
Code enviar.php:
<?php
if(isset($_POST['nombre']) && !empty($_POST['nombre']) &&
isset($_POST['apellidouno']) && !empty($_POST['apellidouno']) &&
isset($_POST['correo']) && !empty($_POST['correo']) &&
isset($_POST['telefono']) && !empty($_POST['telefono']) &&
isset($_POST['comentario']) && !empty($_POST['comentario']))
{
$destino="[email protected]";
$desde="From:"."página web";
$nombre=$_POST['nombre'];
$apellidouno=$_POST['apellidouno'];
$correo=$_POST['correo'];
$telefono=$_POST['telefono'];
$comentario=$_POST['comentario'];
mail($destino,$nombre,$apellidouno,$correo,$telefono,$comentario,$desde);
echo "Correu enviat...";
}else{
echo "Problemas al enviar. Revisi que hagi plenat tots els camps.";
}
?>
The problem is that the messages do not reach their destination and do not know what is due.
Greetings,