Hola,
Estoy utilizando el contactform que tengo preinstalado en mi servidor y le he añadido campos adicionales de forma que el html queda así:
Código HTML:
<form action="/contactform/contactscript.php" method="post" enctype="multipart/form-data" name="form">
<table width="435" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="427" align="left" valign="top" class="Estilo3"> <p>Nombre<span class="Estilo4"> *</span><br />
<input type="text" name="name" size="25" maxlength="200" />
<br />
Apellidos<span class="Estilo4"> *</span><br />
<input type="text" name="name2" size="25" maxlength="200" />
<br />
Tu Email <span class="Estilo4">*</span><br />
<input type="text" name="email" size="25" maxlength="100" />
</p>
<p>¿Qué ocupación te gustaría desempeñar?<br />
<span class="Estilo4"> * Marca una o varias casillas </span><br />
<br />
<label></label>
<label>
<input name="cuidado_enfermos" type="checkbox" id="cuidado_enfermos" value="checkbox" />
</label>
Cuidado de enfermos (Auxiliares/ATS)
<br />
<label>
<input name="atencion_ancianos" type="checkbox" id="atencion_ancianos" value="checkbox" />
</label>
Asistencia a domicilio (atención a ancianos)<br />
<label>
<input name="empleada_hogar" type="checkbox" id="empleada_hogar" value="checkbox" />
</label>
Emplead@ del hogar (internas/externas)
<label></label>
<label><br />
<input name="asistenta" type="checkbox" id="asistenta" value="checkbox" />
</label>
Asistenta (por horas)
<label>
<br />
<input name="cuidado_niños" type="checkbox" id="cuidado_niños" value="checkbox" />
</label>
Cuidado de niños (niñeras/canguros)
<label>
<br />
</label>
<label></label>
<label></label>
<label>
<input name="cocinero" type="checkbox" id="cocinero" value="checkbox" />
</label>
Cociner@
<br />
<label>
<input name="ayudante_cocina" type="checkbox" id="ayudante_cocina" value="checkbox" />
</label>
Ayudante de cocina<br />
<label>
<input name="guardes_finca" type="checkbox" id="guardes_finca" value="checkbox" />
</label>
Guardés de finca<br />
<label>
<input name="conserje" type="checkbox" id="conserje" value="checkbox" />
</label>
Conserje<br />
<label>
<input name="planchadora" type="checkbox" id="planchadora" value="checkbox" />
</label>
Planchadora<br />
<label>
<input name="jardinero" type="checkbox" id="jardinero" value="checkbox" />
</label>
Jardinero<br />
<label>
<input name="chofer" type="checkbox" id="chofer" value="checkbox" />
</label>
Chófer
<br />
<label>
<input name="mayordomo" type="checkbox" id="mayordomo" value="checkbox" />
</label>
Mayordomo<br />
<label>
<input name="camarero" type="checkbox" id="camarero" value="checkbox" />
</label>
Camarer@<br />
<label>
<input name="profesor_particular" type="checkbox" id="profesor_particular" value="checkbox" />
</label>
Profesor particular<br />
<br />
<label> Envía tu currículum <br />
<input type="file" name="file" />
</label>
<p> Comentarios:<br />
<textarea name="msg" cols="25" rows="4"></textarea>
<br />
<label></label>
</p></td>
</tr>
<tr>
<td align="left" valign="top" class="Estilo3"><input type="reset" name="Reset" value="Reset" />
<input type="submit" name="Submit" value="Submit" /> </td>
</tr>
</table>
<p> </p>
</form>
Lo que me falta ahora es el código php que va en el archivo "contactscript.php" y es el siguiente:
Código PHP:
<?php
// VALUES FROM THE FORM
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['msg'];
// ERROR & SECURITY CHECKS
if ( ( !$email ) ||
( strlen($_POST['email']) > 200 ) ||
( !preg_match("#^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$#", $email) )
)
{
print "Error: Invalid E-Mail Address";
exit;
}
if ( ( !$name ) ||
( strlen($name) > 100 ) ||
( preg_match("/[:=@\<\>]/", $name) )
)
{
print "Error: Invalid Name";
exit;
}
if ( preg_match("#cc:#i", $message, $matches) )
{
print "Error: Found Invalid Header Field";
exit;
}
if ( !$message )
{
print "Error: No Message";
exit;
}
// CREATE THE EMAIL
$headers = "Content-Type: text/plain; charset=iso-8859-1\n";
$headers .= "From: $name <$email>\n";
$recipient = "[email protected]";
$subject = "Enviado desde la web";
$message = wordwrap($message, 1024);
// SEND THE EMAIL TO YOU
//mail($recipient, $subject, stripslashes($msg), $headers);
mail($recipient, $subject, $message, $headers);
// REDIRECT TO THE THANKS PAGE
header("location: http://www.cuidadodelhogar.es/enviado.php");
?>
¿Cómo podría modificar el php para que funcione el formulario?
Un saludo y gracias