Wenassss! Ya tengo un form funcionando perfectamente que manda la información a un correo, pero quiero que los usuarios puedan adjuntarme una foto. He buscado por aqui y muchos haceis referencia al PHPMAILER, pero no tengo mucha idea de php y no se como integrar eso. El codigo que tengo por el momento es este:
<html>
<head>
<title>CEPS inscripcions</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#006060" vlink="#006060">
</p>
<a href="http://www.ceps-esqui.com/index.htm" target="_parent"><img src="inscrip.jpg" border="0"></a><?
if (!$HTTP_POST_VARS){
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].url+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<script>
function Validar(form){
if (ceps.numsoci.value == "")
{ alert("Introdueix el teu número de Soci"); ceps.numsoci.focus(); return; }
if (ceps.nom.value == "")
{ alert("Introdueix el teu nom"); ceps.nom.focus(); return; }
ceps.submit();
}
</script>
<form name=ceps action="5.php" method="post">
<?
echo "<table width=\"400\" border=\"0\"><tr><td>Nom i cognoms:</td><td><center><input type=text name=\"nom\" size=20> </td></tr><tr><td>Número de soci:</td> <td><center> <input type=text name=\"numsoci\" size=20> </td> </tr>";
echo "<td> Curs </td>";
echo "<td>";
echo "<p align=\"center\"><select name=\"curs\" onChange=\"MM_jumpMenu('parent',this,0)\">";
echo "<option url=\"envia_form.php#\" value=\"No escollit\"> </option>";
echo "<option url=\"envia_form.php#\" value=\"Curs infantil i jove\" style=\"color:#000000;background-color:#66ccff;\">Curs infantil i jove </option>";
echo "<option url=\"envia_form.php#\" value=\"Curset d'adults\" style=\"color:#000000;background-color:#66ccff;\">Curset d'adults</option>";
echo "<option url=\"envia_formm\" value=\"Sortides de muntanya\" style=\"color:#000000;background-color:#66ccff;\" selected>Sortides de muntanya </option>";
echo "<option url=\"envia_form.php#\" value=\"Snow\" style=\"color:#000000;background-color:#66ccff;\">Snow</option>";
echo "</select></td>";
echo "<td> Nivell: </td>";
echo "<td>";
echo "<p align=\"center\"><select name=\"nivell\">";
echo "<option url=\"envia_form.php#\" value=\"\" selected> </option>";
echo "<option url=\"envia_form.php#\" value=\"Debutant\" style=\"color:#000000;background-color:#66ffff;\">Debutant</option>";
echo "<option url=\"envia_form.php#\" value=\"Iniciat\" style=\"color:#000000;background-color:#66ffff;\">Iniciat</option>";
echo "</select></td>";
echo "<tr>";
echo "<td>Data de la sortida a la muntanya:</td>";
echo "<td><center><input type=text name=\"datas\" size=20> </td>";
echo "</tr>";
echo "<td> Transport: </td>";
echo "<td>";
echo "<p align=\"center\"><select name=\"transport\">";
echo "<option url=\"envia_form.php#\" value=\"\" selected> </option>";
echo "<option url=\"envia_form.php#\" value=\"Debutant\" style=\"color:#000000;background-color:#FF9900;\">Autocar</option>";
echo "<option url=\"envia_form.php#\" value=\"Iniciat\" style=\"color:#000000;background-color:#FF9900;\">Transport propi</option>";
echo "</select></td>";
echo "<tr>";
echo "<td>E-mail:</td>";
echo "<td><center><input type=text name=\"email\" size=20> </td>";
echo "</tr>";
echo "<td><right>Telèfon:</td>";
echo "<td><center><input type=text name=\"telefon\" size=20> </td>";
echo "</tr>";
echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"90000\">Send this file: <input name=\"userfile\" type=\"file\">";
echo "</tr>";
echo "<td><right>Observacions:</td><td><center><textarea name=obs cols=30 rows=6></textarea> </tr></table>";
?>
<center>
</form> <input TYPE="button" value="Enviar" onClick="Validar(this.form)">
<?
}else{
//Enviar el formulari, composar el cos
$msg = "Inscripció a curset\n";
$msg .= "Nom: " . $HTTP_POST_VARS["nom"] . "\n";
$msg .= "Núm.Soci: " . $HTTP_POST_VARS["numsoci"] . "\n";
$msg .= "Curs: " . $HTTP_POST_VARS["curs"] . "\n";
$msg .= "Data de la sortida: " . $HTTP_POST_VARS["datas"] . "\n";
$msg .= "Nivell: " . $HTTP_POST_VARS["nivell"] . "\n";
$msg .= "Transport: " . $HTTP_POST_VARS["transport"] . "\n";
$msg .= "E-mail: " . $HTTP_POST_VARS["email"] . "\n";
$msg .= "Telèfon: " . $HTTP_POST_VARS["telefon"] . "\n";
$msg .= "foto: " . $HTTP_POST_VARS["userfile"] . "\n";
$msg .= "Observacions: " . $HTTP_POST_VARS["obs"] . "\n";
$sender_name = "INSCRIPCIÓ Curset";
$sender_email = "
[email protected]";
$mailheaders = "From: $sender_name <$sender_email>\n";
$mailheaders .= "Reply-To: $sender_email\n\n";
$to = "
[email protected]";
$subject = "Formulari d'inscripció";
// Envio el correu
if (mail($to, $subject, $msg, $mailheaders))
echo "<br><br><br><br><center><img src=http://www.titoworld.com/play/info.gif><br><p></p>La inscripció s'ha realitzat correctament.\n<p> <br><br>";
else
echo "<img src=http://www.titoworld.com/play/stop.gif><br>Hi ha hagut un error en la incripció.<br> Torna a provar-ho en uns minuts<br>";
}
?>
</body>
</html>