Hola, este simple formulario lo realicé ya hace un tiempo y lo suelo utilizar para hacer pruebas por lo que si puede servir de ayuda a alguién habrá cumplido su función.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
############## FORMULARIO.PHP############################## <h1><?php echo EMPLEO ?></h1> <h2><?php echo EMPLEO_H ?></h2> <p class="p_registro"><?php echo EMPLEO_TEXTO ?></p> <form id="empleoformulario" enctype="multipart/form-data" action="<?php echo URL ?>index.php?c=registro_empleo" method="post"> <fieldset> <input type="hidden" name="MAX_FILE_SIZE" value="500000"> <p><label id="label" ><?php echo NOMBRE ?></label><input name="nombre" type="text" id="nombre" placeholder="<?php echo NOMBRE ?>"></p> <p><label id="label" ><?php echo EMAIL ?></label><input name="email" type="email" placeholder="<?php echo EMAIL_INPUT ?>"></p> <p><label id="label" ><?php echo FOTO ?></label> <input name="foto" type="file" ></p> <p><label id="label" ><?php echo CURRICULUM ?></label> <input name="curriculum" type="file" ></p> <p><label id="label"><?php echo TELEFONO ?></label><input name="telefono" type="text" placeholder="+34999999999"></p> <p id="ajaxchapta"><label id="label" >Captcha: "/><input id="chapta" name="chapta" data="<?php $_SESSION["code"] ?>" type="text"></p> <p><label id="label" ><?php echo LEGAL_PD ?></label><?php echo LEGAL_PD_CH ?><input name="legal" type="checkbox"></p> </fieldset> <input id='btnchapta' class='btn' type="submit" accept="image/jpeg" value="<?php echo EMPLEO ?>"> </form> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
##################CHAPTA.PHP###################### if(isset($_SESSION["code"])){unset($_SESSION["code"]);}; session_start(); $code=rand(1000,9999); $_SESSION["code"]=$code; $im = imagecreatetruecolor(50, 24); $bg = imagecolorallocate($im, 22, 86, 165); //background color blue $fg = imagecolorallocate($im, 255, 255, 255);//text color white imagefill($im, 0, 0, $bg); imagestring($im, 5, 5, 5, $code, $fg); header("Cache-Control: no-cache, must-revalidate"); header('Content-type: image/png'); imagepng($im); imagedestroy($im); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
<?PHP ##############ENVIO.PHP#################### if($_POST["chapta"]==$_SESSION["code"]){ if(!isset($_SESSION['registroempleo'])){ if(!empty($_POST)){ session_start(); $_SESSION['registroempleo'] = "true"; //FORMULARIO DE REGISTRO VARIABLES echo "Estoy dentro "; print_r($_POST); img(); curriculum(); //DATOS FORMULARIO EMPLEO $nombre = $_POST["nombre"]; $email = $_POST["email"]; $foto = $_FILES["foto"]['name']; $curriculum = $_FILES["curriculum"]['name']; $telefono =$_POST["telefono"]; $proceso_email=true; $proceso_dni=true; //INSERTAR EN LA BASE DE DATOS $tabla = "empleo"; $parametros= "nombre, email, foto, curriculum, telefono"; $valores = "values('".$nombre."','".$email."','".$foto."','".$curriculum."','".$telefono."')"; insertar($tabla,$parametros,$valores); //MOSTRAR CUANDO SE ENVÍA LA INFO DE EMPLEO. echo "<div class=\"ENVIO\">"; echo "<h1>".REGISTRO_OK_EMPLEO."</h1>"; echo "<h2>".REGISTRO_H_EMPLEO."</h2>"; echo "<p class=\"p_registro\">".REGISTRO_TEXTO_OK."</p>"; echo "</div>"; $correo = CORREO_CONTACTO ; $mail = $_POST["email"]; envio_correo_registro_empleo($nombre,$foto,$correo,$curriculum,$telefono,$mail); echo "<div class=\"errores\">"; if($proceso_email==false){ echo '<script type="text/javascript">window.location.href="'.URL.'index.php";</script>'; echo ERROR_EMAIL ; } if($proceso_dni==false){ echo '<script type="text/javascript">window.location.href="'.URL.'index.php";</script>'; echo ERROR_NIF ; } echo "</div>"; }//SI POST NO CONTIENE CONTENIDO }else{ echo '<script type="text/javascript">window.location.href="'.URL.'index.php";</script>'; }//VARIABLE DE SSESION }else{ echo $html='<script language="javascript" type="text/javascript"> alert('."'".CHATPTA."'".'); </script>'; } ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
function img() { { // obtenemos los datos del archivo $tamano = $_FILES["foto"]['size']; $tipo = $_FILES["foto"]['type']; $archivo = $_FILES["foto"]['name']; $prefijo = substr(md5(uniqid(rand())),0,6); if ($archivo != "") { // guardamos el archivo a la carpeta files $destino = HOST."/media/img/ORIGINAL/".$prefijo."_".$archivo; if (copy($_FILES['foto']['tmp_name'],$destino)) { $status = "Archivo subido: <b>".$archivo."</b>"; } else { $status = "Error al subir el archivo"; } } else { $status = "Error al subir archivo"; } } } function curriculum() { { // obtenemos los datos del archivo $tamano = $_FILES["curriculum"]['size']; $tipo = $_FILES["curriculum"]['type']; $archivo = $_FILES["curriculum"]['name']; $prefijo = substr(md5(uniqid(rand())),0,6); if ($archivo != "") { // guardamos el archivo a la carpeta files $destino = HOST."/media/c/".$prefijo."_".$archivo; if (copy($_FILES['curriculum']['tmp_name'],$destino)) { $status = "Archivo subido: <b>".$archivo."</b>"; } else { $status = "Error al subir el archivo"; } } else { $status = "Error al subir archivo"; } } } |