25/10/2012, 17:56
|
| | | Fecha de Ingreso: julio-2012 Ubicación: Bs.As. Argentina
Mensajes: 507
Antigüedad: 11 años, 9 meses Puntos: 86 | |
Respuesta: mail + registro en excel hola prueba y nos cuenta como anduvo Código PHP:
<html> <head><title> <?php //Code by apg88 "apgForm(toExcel) 1.4" // Determine if the form was sent through the GET methog or the POST method. if($_GET){ $array = $_GET; }else if($_POST){ $array = $_POST; } else { echo "You must Access this file through a form."; // If someone accesses the file directly, it wont work :) } $nombre_eq = $_POST['nombre']; $modalidad = $_POST['modalidad']; $int1=$_POST['integrante1']; $int1ci=$_POST['integrante1ci']; $int1tel=$_POST['integrante1telefono']; $int1cel=$_POST['integrante1celular']; $int1email=$_POST['integrante1email']; $int1rem=$_POST['integrante1remera']; $int2=$_POST['integrante2']; $int2ci=$_POST['integrante2ci']; $int2tel=$_POST['integrante2telefono']; $int2cel=$_POST['integrante2celular']; $int2email=$_POST['integrante2email']; $int2rem=$_POST['integrante2remera']; $header = 'From: ' . $int1email . " \r\n"; $header .= "X-Mailer: PHP/" . phpversion() . " \r\n"; $header .= "Mime-Version: 1.0 \r\n"; $header .= "Content-type: text/html\r\n"; $mensaje = "Este mensaje fue enviado por desde el formulario de pre-inscripción.<br />"; $mensaje .= "Estos son los datos enviados: <br /><br />"; $mensaje .= "<b>Nombre del Equipo: </b>".$nombre_eq."<br />"; $mensaje .= "<b>Modalidad: </b>".$modalidad."<br />"; $mensaje .= "-----------------------------------------------------<br />"; $mensaje .= "<b>Nombre integrante 1: </b>".$int1."<br />"; $mensaje .= "<b>Cédula Nº: </b>".$int1ci."<br />"; $mensaje .= "<b>Teléfono: </b>".$int1tel."<br />"; $mensaje .= "<b>Celular: </b>".$int1cel."<br />"; $mensaje .= "<b>Email: </b>".$int1email."<br />"; $mensaje .= "<b>Tamaño de remera: </b>".$int1rem."<br />"; $mensaje .= "-----------------------------------------------------<br />"; $mensaje .= "<b>Nombre integrante 2: </b>".$int2."<br />"; $mensaje .= "<b>Cédula Nº: </b>".$int2ci."<br />"; $mensaje .= "<b>Teléfono: </b>".$int2tel."<br />"; $mensaje .= "<b>Celular: </b>".$int2cel."<br />"; $mensaje .= "<b>Email: </b>".$int2email."<br />"; $mensaje .= "<b>Tamaño de remera: </b>".$int2rem."<br />"; $mensaje .= "Enviado el " . date('d/m/Y', time()); $para = '[email protected]'; $asunto = 'Pre-inscripciones Mandu´ara Light '.date("Y"); mail($para, $asunto, utf8_decode($mensaje), $header); if(!$array['title']){ // if the title wasnt sent through the form, it will become whatever you set it equal to in the next line $array['title'] = "apgForm"; //Set default title to be displayed } echo $array['title'] .'</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'; //Check if the filename was sent through the form or not if(!$array['filename']){ // if the filename wasnt sent through the form, it will become form.xls, you can change the default if you want. $array['filename'] = "form.xls"; //Set the file to save the information in } else { if(!(stristr($array['filename'],".xls"))){ $array['filename'] = $array['filename'] . ".xls"; } } // Change this to whatever you want the users to see after the form is processed $continue = ' Here is a the Comment form your info was just sent to <a href="test.xls">Click Here</a> to see the excel file.<br> <a href = "index.php">Click Here</a> To Return to apgForm '; // Change this to the character(s) you want to be placed instead of line breaks(new line, enter, etc) $lbChar = " "; // default is a space, you may change it to whatever you want //------------------------------------------------------------------------------------- //----------------You do not need to change anything below this line------------------- //------------------------------------------------------------------------------------- // Define the tab and carriage return characters: $tab = "\t"; //chr(9); $cr = "\n"; //chr(13); if($array){ // Make The Top row for the excel file and store it in the $header variable $keys = array_keys($array); foreach($keys as $key){ if(strtolower($key) != 'filename' && strtolower($key) != 'title'){ $header .= $key . $tab; } } $header .= $cr; //Make the line with the contents to write to the excel file. foreach($keys as $key){ if(strtolower($key) != 'filename' && strtolower($key) != 'title'){ $array[$key] = str_replace("\n",$lbChar,$array[$key]); $array[$key] = preg_replace('/([\r\n])/e',"ord('$1')==10?'':''",$array[$key]); $array[$key] = str_replace("\\","",$array[$key]); $array[$key] = str_replace($tab, " ", $array[$key]); $data .= $array[$key] . $tab ; } } $data .= $cr; if (file_exists($array['filename'])) { $final_data = $data; //if the file does exist, then only write the information the user sent } else { $final_data = $header . $data; //if file does not exist, write the header(first line in excel with titles) to the file } // open the file and write to it $fp = fopen($array['filename'],"a"); // $fp is now the file pointer to file $array['filename'] if($fp){ fwrite($fp,$final_data); //Write information to the file fclose($fp); // Close the file echo "<script language=Javascript> location.href=\"gracias.html\"; </script>"; } else { echo "</header><body>"; echo "Error al recibir los datos!" ; } } ?> </body> </html>
__________________ Saludos!
---------------------------------------------------------- |