Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/10/2010, 20:54
isabellawebs
Usuario no validado
 
Fecha de Ingreso: diciembre-2009
Ubicación: Bogotá
Mensajes: 462
Antigüedad: 16 años, 9 meses
Puntos: 18
Guardar en bd y enviar mail se puede?

Hola chicos: Al registrarse alguien en mi web, me quedan guardados sus datos en mi bd.

Puedo hacer que al mismo tiempo se me envíe un email con sus datos (con los que se registró)?

Gracias, uso php.

Si se puede, aqui esta mi codigo para quien me pueda orientar.

Código PHP:
<?php require_once('Connections/segurodb.php'); ?>
<?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;
}
}

// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset(
$_POST[$MM_flag])) {
  
$MM_dupKeyRedirect="yaexiste.php";
  
$loginUsername = $_POST['nit'];
  
$LoginRS__query = sprintf("SELECT nit FROM registro WHERE nit=%s", GetSQLValueString($loginUsername, "int"));
  
mysql_select_db($database_segurodb, $segurodb);
  
$LoginRS=mysql_query($LoginRS__query, $segurodb) or die(mysql_error());
  
$loginFoundUser = mysql_num_rows($LoginRS);

  
//if there is a row in the database, the username was found - can not add the requested username
  
if($loginFoundUser){
    
$MM_qsChar = "?";
    
//append the username to the redirect page
    
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
    
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
    
header ("Location: $MM_dupKeyRedirect");
    exit;
  }
}

$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 registro (nit, email, telefono, empresa) VALUES (%s, %s, %s, %s)",
                       
GetSQLValueString($_POST['nit'], "text"),
                       
GetSQLValueString($_POST['email'], "text"),
                       
GetSQLValueString($_POST['telefono'], "text"),
                       
GetSQLValueString($_POST['empresa'], "text"));

  
mysql_select_db($database_segurodb, $segurodb);
  
$Result1 = mysql_query($insertSQL, $segurodb) or die(mysql_error());

  
$insertGoTo = "gracias.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_segurodb, $segurodb);
$query_rc_registro = "SELECT * FROM registro";
$rc_registro = mysql_query($query_rc_registro, $segurodb) or die(mysql_error());
$row_rc_registro = mysql_fetch_assoc($rc_registro);
$totalRows_rc_registro = mysql_num_rows($rc_registro);
?><!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=iso-8859-1">
<title>WEB</title><link rel="shortcut icon" href="favicon.ico"  />
<link href="css/css.css" rel="stylesheet" type="text/css" />
<script src="js/AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">

</script>
</head>
<body>
<div align="center">
  <table width="835" border="0" cellpadding="0" cellspacing="0">
    <!--DWLayoutTable-->
    <!--TABLA PRINCIPAL-->
    <!--FIN TABLA PRINCIPAL-->
    <tr>
      <td height="328" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <!--TABLA SECUNDARIA PARA BANNER-->
        <tr>
          <td width="835" height="328" valign="top"><!--CELDA SECUNDARIA PARA BANNER-->
            <script type="text/javascript">
</noscript></td>
          </tr>
      </table></td>
    </tr>
    <tr>
      <td height="60" colspan="3" align="center" valign="middle" class="titulos_contenido">Apreciado cliente: Ll&eacute;ne el formulario en su totalidad, sin dejar campos vac&iacute;os o sin completar. Sus datos quedar&aacute;n grabados y nosotros estaremos confirmando su registro en menos de 24 horas.</td>
    </tr>
    <tr>
      <td width="258" height="210">&nbsp;</td>
      <td width="317" valign="top"><table width="317" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        
        <tr>
          <td width="317" height="188" valign="top">&nbsp;
            <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
              <table align="center">
                <tr valign="baseline">
                  <td align="right" nowrap="nowrap" class="campos">Nit:</td>
                    <td align="left"><input name="nit" type="text" class="campos2" value="" size="20" /></td>
                  </tr>
                <tr valign="baseline">
                  <td align="right" nowrap="nowrap" class="campos">Email:</td>
                    <td align="left"><input name="email" type="text" class="campos2" value="" size="30" /></td>
                  </tr>
                <tr valign="baseline">
                  <td align="right" nowrap="nowrap" class="campos">Tel&eacute;fono:</td>
                    <td align="left"><input name="telefono" type="text" class="campos2" value="" size="7" maxlength="7" /></td>
                  </tr>
                <tr valign="baseline">
                  <td align="right" nowrap="nowrap" class="campos">Empresa:</td>
                    <td align="left"><input name="empresa" type="text" class="campos2" id="empresa" value="" size="32" /></td>
                  </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right">&nbsp;</td>
                    <td align="center" valign="middle"><input type="submit" class="campos2" value="Grabar" /></td>
                  </tr>
                </table>
                <input type="hidden" name="MM_insert" value="form1" />
            </form></td>
          </tr>
        <tr>
          <td height="22">&nbsp;</td>
          </tr>
        
        
      </table></td>
    <td width="260">&nbsp;</td>
    </tr>
    
    <tr>
      <td height="37" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <!--TABLA BARRA-->
        <tr>
          <td width="835" height="37" valign="top"><!--CELDA BARRA-->
            <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','835','height','37','src','swf/barra_beh','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','wmode','transparent','movie','swf/barra_beh' ); //end AC code
            </script>
              <noscript>
                <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="835" height="37">
                  <param name="movie" value="swf/barra_beh.swf" />
                  <param name="quality" value="high" />
                  <param name="wmode" value="transparent" />
                  <embed src="swf/barra_beh.swf" width="835" height="37" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>
            </object></noscript></td>
          </tr>
      </table></td>
    </tr>
    <tr>
      <td height="49" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <!--TABLA FIRMAS-->
        <tr>
          <td width="835" height="49" align="center" valign="middle" class="texto_firma"><!--TERMINA CELDA FIRMAS-->
            <p>
        </tr>
      </table></td>
    </tr>
  </table>
</div>
</body>
</html>
<?php
mysql_free_result
($rc_registro);
?>
Gracias.

Última edición por isabellawebs; 16/10/2010 a las 21:17