Guardar en formualrio y enviar por email
Buenas tardes.Tengo el siguiente formulario que me introduce los siguientes datos en una tabla de mi base datos. Lo que me gustaria saber hacer es que me mostrara los datos que he introducido en este formulario en una pagina diferente para que la vea el usuario que introdujo los datos y que ademas me enviara a mi un email con los datos que me muestra esa pagina al usuario.
Sabriais decirme como?
Sabriais decirme como?
<?php require_once('Connections/Conexion.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO `cliente` (nombre, apellidos, email) VALUES (%s, %s, %s)", GetSQLValueString($_POST['nombre'], "text"), GetSQLValueString($_POST['apellidos'], "text"), GetSQLValueString($_POST['email'], "text")); mysql_select_db($database_Conexion, $Conexion); $Result1 = mysql_query($insertSQL, $Conexion) or die(mysql_error()); $insertGoTo = "confirmacion.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_Conexion, $Conexion); $query_ConsCli = "SELECT `cliente`.nombre, `cliente`.apellidos, `cliente`.email FROM `cliente`"; $ConsCli = mysql_query($query_ConsCli, $ConexionHYC) or die(mysql_error()); $row_ConsCli = mysql_fetch_assoc($ConsCli); $totalRows_ConsCli = mysql_num_rows($ConsCli); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> </head> <body> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Nombre:</td> <td><input type="text" name="nombre" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Apellidos:</td> <td><input type="text" name="apellidos" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Email:</td> <td><input type="text" name="email" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Insertar registro" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> <p> </p> </body> </html> <?php mysql_free_result($ConsCli); ?>
0
Puntos
Puntos
4518
Visitas
Visitas
4
Resp
Resp
Por Ramos hace 126 meses
Principiante
Respuesta #1
Perdon... Mi duda es la siguiente.... Sobre el formaulario anterior que guarda esos datos en una base de datos... Como puedo hacer para que la muestre en una pagina diferente para que el usuario vea lo almacenado para su informacion y que ademas en envie a mi un email con los datos de ese registro almacenado en la base de datos....
Disculpen mi error...
Disculpen mi error...
0
Puntos
Puntos
Por Ramos hace 126 meses
Principiante
Respuesta #2
Ok, para hacer que en una página aparezca lo que escribiste en el formulario, como para verificar pues, no hace falta introducirlo a la base de datos, tan solo debes colocar en el action=" " la página a donde quieres ver los datos, y en esa página mediante PHP extraer la información escrita en las cajas de texto. Te muestro mejor con un ejemplo.
Sobre enviar un email, no se mucho pero creo que no te funcionará a modo localhost.
<!DOCTYPE html> <html lang="es"> <head> <title>Prueba de formulario</title> </head> <body> <form action="muestra.php" method="post" name="formulario"> <input type="text" size="60" placeholder="Nombre" name="nombre"> <br> <input type="email" size="60" placeholder="Correo" name="email"> <br> <input type="submit" value="Enviar"> </form> </body> </html>Ésta página es el formulario, que enviará la información a muestra.php
<!DOCTYPE html> <html lang="es"> <head> <title>Prueba de formulario</title> <style> body { font-family: Calibri; color: #555; } </style> </head> <body> Tus datos son los siguientes: <br> <br> <?php $nombre = $_POST['nombre']; $correo = $_POST['email']; echo 'Nombre: '.$nombre; echo '<br>'; echo 'Correo: '.$correo; ?> </body> </html>Ésta página es la que muestra la información. Luego, podrías colocarle un texto que diga algo como: Si la información es correcta, haga click en aceptar. Y al hacer click en aceptar sí se guarde la información en la base de datos.
Sobre enviar un email, no se mucho pero creo que no te funcionará a modo localhost.
Respuesta #3
si quieres que cada vez que se formule un nuevo formulario te llegue un correo electrónico para informarte justo después de es fragmento
<?php $insertSQL = sprintf("INSERT INTO `cliente` (nombre, apellidos, email) VALUES (%s, %s, %s)", GetSQLValueString($_POST['nombre'], "text"), GetSQLValueString($_POST['apellidos'], "text"), GetSQLValueString($_POST['email'], "text")); mysql_select_db($database_Conexion, $Conexion); $Result1 = mysql_query($insertSQL, $Conexion) or die(mysql_error()); ?>tienes que poner algo así
<?php $para = 'webmaster@example.com'; // A este email llegara el correo $titulo = 'Nuevo formulario'; $mensaje = $_POST['nombre'].' '.$_POST['apellidos'].' acaba de enviar un nuevo formulario y su email es '.$_POST['email']; $cabeceras = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: '.$_POST['email'].'' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($para, $titulo, $mensaje, $cabeceras); ?>el código completo
<?php $insertSQL = sprintf("INSERT INTO `cliente` (nombre, apellidos, email) VALUES (%s, %s, %s)", GetSQLValueString($_POST['nombre'], "text"), GetSQLValueString($_POST['apellidos'], "text"), GetSQLValueString($_POST['email'], "text")); mysql_select_db($database_Conexion, $Conexion); $Result1 = mysql_query($insertSQL, $Conexion) or die(mysql_error()); $para = 'webmaster@example.com'; // A este email llegara el correo $titulo = 'Nuevo formulario'; $mensaje = $_POST['nombre'].' '.$_POST['apellidos'].' acaba de enviar un nuevo formulario y su email es '.$_POST['email']; $cabeceras = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: '.$_POST['email'].'' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($para, $titulo, $mensaje, $cabeceras); ?>
0
Puntos
Puntos
Por alber hace 122 meses
Administrador