formulario.html
Código:
<html>
<link href="mihoja.css" rel="stylesheet" type="text/css" />
<body>
<body bgcolor="#000000">
<div id="Layer5"></div>
<div id="Layer3">
<form name="form1" method="post" action="enviar.php">
<table width="430" border="1">
<!--DWLayoutTable-->
<tr>
<td width="119"><span class="titulares">Nombres:</span></td>
<td width="295"><span class="Estilo3">
<label>
<input name="nombres" type="text" id="nombres">
</label>
</span></td>
</tr>
<tr>
<td width="119"><span class="titulares">Apellidos:</span></td>
<td width="295"><span class="Estilo3">
<label>
<input name="apellidos" type="text" id="apellidos" />
</label>
</span></td>
</tr>
<tr>
<td width="119"><span class="titulares">Edad</span></td>
<td width="295"><span class="Estilo3">
<label>
<input name="edad" type="text" id="edad">
</label>
</span></td>
</tr>
<tr>
<td width="119"><span class="titulares">Nick:</span></td>
<td width="295"><span class="Estilo3">
<label>
<input name="nick" type="text" id="nick">
</label>
</span></td>
</tr>
<tr>
<td width="119"><span class="titulares">Correo:</span></td>
<td width="295"><span class="Estilo3">
<label>
<input name="correo" type="text" id="correo">
</label>
</span></td>
</tr>
<tr>
<td class="titulares">Telefono:</td>
<td><label>
<input name="tel" type="text" id="tel">
</label></td>
</tr>
<tr>
<td width="119"><span class="titulares">Genero Favorito: </span></td>
<td width="295"><label>
<select name="select" size="1" multiple>
<option value="A" selected>Metal Alternativo</option>
<option value="B" selected>Death Metal</option>
<option value="C" selected>Gothic Metal</option>
<option value="D">Grindcore</option>
<option value="E">Thrash Metal</option>
<option value="F">Black Metal</option>
<option value="G">Doom Metal</option>
<option value="H">Hardcore</option>
<option value="I">Power Metal</option>
</select>
</label></td>
</tr>
<tr>
<td><span class="titulares">Banda(s) Favorita: </span></td>
<td><span class="Estilo3">
<label>
<input name="favorita" type="text" id="favorita" />
</label>
</span></td>
</tr>
<tr>
<td width="119"><span class="Estilo3">
<label></label>
<label></label>
</span></td>
<td width="295"><span class="Estilo3">
<label>
<input name="restablecer" type="reset" id="restablecer" value="Restablecer" />
<input type="submit" name="Submit" value="Enviar" />
</label>
</span></td>
</tr>
</table>
<label></label>
<p> </p>
</form>
</div>
</body>
</html>
Y este es el codigo del PHP:
enviar.php
Código:
<?php
//recibe las variables del html que son datos del usuario, solamente campos de texto
$nombre= $_POST['nombres'];
$apellido=$_POST['apellidos'];
$edad=$_POST['edad'];
$nick=$_POST['nick'];
$correo=$_POST['correo'];
$telefono=$_POST['tel'];
$favoritas=$_POST['favorita'];
//recibe la variable de la lista
switch ($_POST['genero']){
case A:
$gustos="Metal Alternanito";
break;
case B:
$gustos="Death Metal";
break;
case C:
$gustos="Gothic Metal";
break;
case D:
$gustos="Grindcore";
break;
case E:
$gustos="Thrash Metal";
break;
case F:
$gustos="Black Metal";
break;
case G:
$gustos="Doom Metal";
break;
case H:
$gustos="Hardcore";
break;
case I:
$gustos="Power Metal";
break;
}//cierre del switch
//revisamos que los campos no estén vacios
if(empty ($nombres)) $fallo.="No tecleaste tu nombre, \n";
if (empty($apellidos)) $fallo.="No tecleaste tus apellidos, \n";
if (empty($edad)) $fallo.="No tecleaste tu edad, \n";
if (empty($nick)) $fallo.="No tecleaste tu Nick, \n";
if (empty($correo)) $fallo.="No tecleaste tu correo, \n";
if (empty ($telefono)) $fallo.="No tecleaste tu telefono, \n";
if (empty ($favoritas)) $fallo.="No ingresaste ninguna banda favorita";
//validamos que el correo sea correcto
if ((strlen($correo) >= 6) && (substr_count($correo,"@") == 1) && (substr($correo,0,1) != "@") && (substr($correo,strlen($correo)-1,1) != "@")){
if ((!strstr($correo,"'")) && (!strstr($correo,"\"")) && (!strstr($correo,"\\")) && (!strstr($correo,"\$")) && (!strstr($correo," "))) {
if (substr_count($correo,".")>= 1){
$aux = substr(strrchr ($correo, '.'),1);
if (strlen($aux)>1 && strlen($aux)<5 && (!strstr($aux,"@")) ){
$aux2 = substr($correo,0,strlen($correo) - strlen($aux) - 1);
}
}
}//fin del if
else{
$fallo.="El correo electrónico que ingresaste no es valido";
} //fin del else
//guardo la cadena del fallo en v
$idiota=$fallo;
$Fallo==””;
if ($fallo==""){//Si no hubo errores
$caracteres = 8; // numero de caracteres a visualizar
$random_pass = substr(md5(rand()),0,$caracteres);
echo "Tu Registro se realizo con éxito, en los prócimos minutos recibirás un correo con tu confirmación de registro y tu password, Gracias por registrarte. <br>
Estos son los datosd que ingresaste: <br>
Nombre : $nombres \n $apellidos<br>
Teléfono: $telefono <br>
Edad: $edad <br>
Correo: $correo <br>
Nick: $nick <br>
Tu(s) Banda Favorita: $favoritas <br>
Password: $y";
//envia al correo del usuario
$asunto= "Registro en Metal Mexica" ;
$MailTo="$sik_ide@hotmail.com";
$dia=date("m.d.Y");
$hora=date("H:i:s");
$contenido="
El moderador de Metal Mexica te ha enviado estemensaje el $dia a las $hora: \n\n
_______________________________________________________________________\n
Asunto: $asunto\n
________________________________________________________________________\n
Estos son tus datos a confirmar \n
Nombre : $nombres \n
Apellido : $apellidos \n
Teléfono : $tel \n
Correo : $correo \n
Nick : $nick \n
Password : $y \n
________________________________________________________________________\n
Género Favorito \n
$gustos
Para confirmar tu registro visita este link: http://tekantoferiacristonegro.iespana.es/form/confirmacion.html
_____________________________________________________________________\n
";
mail($MailTo, "$asunto (de Metal Mexica )", $contenido, "From: $correo");
mail($correo, "$asunto (de Metal Mexica)", $contenido, "From: $correo"); }
else{
//por si hubo campos vacios o el e-mail era incorrecto hace:
echo "Lo sentimos el envio no sepudo realizar, porfavor:<br>
$idiota <br>
Regresa al formulario y corrige los errores";}
?>
Tambien me pidieron que hiciera esto pero no tengo idea como hacerlo. lei lo del phpmailer pero la verdad no lo entendi.
Postales virtuales.
El usuario podrá elegir una imagen y agregarle un mensaje para su envío por e-mail al destinatario.
La imagen llegará con el mensaje y los datos del remitente.
espero alguien me pueda ayudar es urgente