Foros del Web » Programando para Internet » PHP »

Formulario con DB y envie mail

Estas en el tema de Formulario con DB y envie mail en el foro de PHP en Foros del Web. hola a todos, estoy con un proyecto y me frené en este inconveniente... Tengo un formulario qeu quiero qeu se guarde en una DB y ...
  #1 (permalink)  
Antiguo 30/07/2009, 13:22
 
Fecha de Ingreso: mayo-2009
Mensajes: 68
Antigüedad: 14 años, 10 meses
Puntos: 0
Formulario con DB y envie mail

hola a todos, estoy con un proyecto y me frené en este inconveniente...
Tengo un formulario qeu quiero qeu se guarde en una DB y además envíe un mail con los mismos datos... lo logré pero por separado y cuanlo pongo todo junto me llega el mail pero vacio...
me podrían dar una mano?...
acá va el codigo:
<?php require_once('direcciondelaconex'); ?>
<?php
$nombre = $_POST['Nombres'];
$apellido = $_POST['Apellido'];
$telefono = $_POST['Telefono'];
$Correo = $_POST['Correo'];
$Carrera = $_POST['Carrera'];
$Materia = $_POST['Materia'];
$Comentario = $_POST['Comentarios'];

$header = 'From: ' . $Correo . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";

$mensaje = "Este mensaje fue enviado por " . $nombre . ", " . $apellido . " \r\n";
$mensaje .= "telefono: " . $telefono . " \r\n";
$mensaje .= "Correo: " . $Correo . " \r\n";
$mensaje .= "Carrera: " . $_POST['Carrera'] . " \r\n";
$mensaje .= "Materia: " . $_POST['Materia'] . " \r\n";
$mensaje .= "Comentarios: " . $_POST['Comentarios'] . " \r\n";
$mensaje .= "Enviado el " . date('d/m/Y', time());

$para = 'mimail';
$asunto = 'Formulario de Reserva banco';

mail($para, $asunto, utf8_decode($mensaje), $header);

?>

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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 reserva_banco (Nombres, Apellido, Telefono, Correo, Carrera, Materia, Comentarios) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Nombres'], "text"),
GetSQLValueString($_POST['Apellido'], "text"),
GetSQLValueString($_POST['Telefono'], "text"),
GetSQLValueString($_POST['Correo'], "text"),
GetSQLValueString($_POST['Carrera'], "text"),
GetSQLValueString($_POST['Materia'], "text"),
GetSQLValueString($_POST['Comentarios'], "text"));

mysql_select_db($database_conex_piero, $conex_piero);
$Result1 = mysql_query($insertSQL, $conex_piero) or die(mysql_error());

$insertGoTo = "link del enviar phph es el mismo que este archivo";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

?><html>
<head>

<title>piero</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<table width="639" height="478" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td>Muchas gracias por enviar el formulario</td>
</tr>
</table>

</body>
</html>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:51.