Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] Activar cuenta enviando un mail

Estas en el tema de Activar cuenta enviando un mail en el foro de PHP en Foros del Web. Hola comunidad, saludos desde Bogotá - Colombia, mi consulta es la siguiente: Tengo dos archivos, uno de registro y el otro de registro ok; todo ...
  #1 (permalink)  
Antiguo 04/03/2014, 22:59
Avatar de geovannimendoza  
Fecha de Ingreso: noviembre-2013
Mensajes: 15
Antigüedad: 10 años, 5 meses
Puntos: 0
Pregunta Activar cuenta enviando un mail

Hola comunidad, saludos desde Bogotá - Colombia, mi consulta es la siguiente:

Tengo dos archivos, uno de registro y el otro de registro ok; todo lo he realizado en DreamWeaver, solicito su ayuda ya que no sé como enviar el correo de validación, esto es lo que tengo.

archivo registro y formulario.


Código PHP:
<?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;
}
}
/*****************************************************************

            Verificiar email si existe      

/******************************************************************/

// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset(
$_POST[$MM_flag])) {
  
$MM_dupKeyRedirect='email_repetido.php?recordSEG='.$_GET["recordSEG"].'';
  
$loginUsername $_POST['strEmail'];
  
$LoginRS__query sprintf("SELECT strEmail FROM tblusuario WHERE strEmail=%s"GetSQLValueString($loginUsername"text"));
  
mysql_select_db($database_conexion$conexion);
  
$LoginRS=mysql_query($LoginRS__query$conexion) 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;
  }
}
  

       
$activar genera_random(20);


$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 tblusuario (strNombre, strApellido1, strApellido2, intTipoDocumento, strDocumento, strPassword, intSexo, strOcupacion, strDireccion, intDepartamento, intCiudad, strTelFijo, strCel, strEmail, intDia, intMes, strAno, intEstado, strActivar) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['strNombre'], "text"),
                       
GetSQLValueString($_POST['strApellido1'], "text"),
                       
GetSQLValueString($_POST['strApellido2'], "text"),
                       
GetSQLValueString($_POST['intTipoDocumento'], "int"),
                       
GetSQLValueString($_POST['strDocumento'], "text"),
                       
GetSQLValueString(md5($_POST['strPassword']), "text"),
                       
GetSQLValueString($_POST['intSexo'], "int"),
                       
GetSQLValueString($_POST['strOcupacion'], "text"),
                       
GetSQLValueString($_POST['strDireccion'], "text"),
                       
GetSQLValueString($_POST['intDepartamento'], "int"),
                       
GetSQLValueString($_POST['intCiudad'], "int"),
                       
GetSQLValueString($_POST['strTelFijo'], "text"),
                       
GetSQLValueString($_POST['strCel'], "text"),
                       
GetSQLValueString($_POST['strEmail'], "text"),
                       
GetSQLValueString($_POST['intDia'], "int"),
                       
GetSQLValueString($_POST['intMes'], "int"),
                       
GetSQLValueString($_POST['strAno'], "int"),
                       
GetSQLValueString($_POST['intEstado'], "int"),
                       
GetSQLValueString($_POST['strActivar'], "text"));

  
mysql_select_db($database_conexion$conexion);
  
$Result1 mysql_query($insertSQL$conexion) or die(mysql_error());
  
  
$insertGoTo "registro_ok.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_Usuario "SELECT * FROM tblusuario";
$Usuario mysql_query($query_Usuario$conexion) or die(mysql_error());
$row_Usuario mysql_fetch_assoc($Usuario);
$totalRows_Usuario mysql_num_rows($Usuario);

mysql_select_db($database_conexion$conexion);
$query_Departamento "SELECT * FROM tbldepartamento ORDER BY tbldepartamento.strNombre ASC";
$Departamento mysql_query($query_Departamento$conexion) or die(mysql_error());
$row_Departamento mysql_fetch_assoc($Departamento);
$totalRows_Departamento mysql_num_rows($Departamento);

mysql_select_db($database_conexion$conexion);
$query_Ciudad "SELECT * FROM tblciudad ORDER BY tblciudad.strNombre ASC";
$Ciudad mysql_query($query_Ciudad$conexion) or die(mysql_error());
$row_Ciudad mysql_fetch_assoc($Ciudad);
$totalRows_Ciudad mysql_num_rows($Ciudad);

mysql_select_db($database_conexion$conexion);
$query_Dia "SELECT * FROM tbldia";
$Dia mysql_query($query_Dia$conexion) or die(mysql_error());
$row_Dia mysql_fetch_assoc($Dia);
$totalRows_Dia mysql_num_rows($Dia);

mysql_select_db($database_conexion$conexion);
$query_Mes "SELECT * FROM tblmes";
$Mes mysql_query($query_Mes$conexion) or die(mysql_error());
$row_Mes mysql_fetch_assoc($Mes);
$totalRows_Mes mysql_num_rows($Mes);
?>

archivo registro_ok.php que me da Dreamweaver



<?php require_once('Connections/conexion.php'); ?>

Código PHP:
    <!--    Envio correo de confirnación    -->
     <?php
     
    $email 
$_POST["strEmail"];
    
$nombre $_POST["strNombre"];
    
$apellido1 $_POST["strApellido1"];
    
$activar $_POST["strActivar"];

 
       
$path "http://localhost/xxxx/";
       
$activarLink $path."activar_registro.php?id=".$nombre['idUsuario']."&activarKey=".$activar.""
       
       
       
$contenido '<p>Hola<br>'.$nombre.'&nbsp;'$apellido1.'<br>'.$razonsocial.'<br>
          </p>
      <p>Estás a solo un paso de completar el registro en nuestra tienda virtual, solo debes dar click en el enlace para activar tu cuenta. Con esta validación y activación, confirmamos si el correo que registrado en válido para enviar futura información.<br><br>
      <a HREF ="'
.$activarLink.'">'.$activarLink.'</a> 
      
      </p>
      
      
      
      <p>Gracias por el tiempo y querer ser cliente de xxx</p></td>'
;
      
      
$asunto 'Activar cuenta de usuario - Tienda Virtual';
    
EnvioCorreoHTML($destinatario$contenido$asunto);
    

    
    
?>
Los datos de Nombre, email, apellido, etc.. no me los trae, no sé que estaré haciendo mal.
El error de SMTP es normal que lo bote porque no estoy en un servidor con esta opción activada; ¿Será que por lo mismo no me trae los datos?.

He mirado y realizado los pasos que he encontrado es el foro pero la verdad no logro entender, ya que como les comenté anteriormente, todo lo hago por Dreamweaver, entonces quedó perdido.

Gracias por su ayuda.

Quedo atento.
  #2 (permalink)  
Antiguo 05/03/2014, 04:35
Avatar de Heli0s  
Fecha de Ingreso: abril-2010
Mensajes: 789
Antigüedad: 14 años
Puntos: 40
Respuesta: Activar cuenta enviando un mail

Si no te lo recoge es porque no estas enviando los datos correctamente por POST.

Un saludo
  #3 (permalink)  
Antiguo 05/03/2014, 21:57
Avatar de geovannimendoza  
Fecha de Ingreso: noviembre-2013
Mensajes: 15
Antigüedad: 10 años, 5 meses
Puntos: 0
Pregunta Respuesta: Activar cuenta enviando un mail

Hola Heli0s, gracias por tu respuesta, eso es lo que no sé como revisar, no sé que estoy haciendo mal, mira este es el formulario de registro.

Formulario.


Código HTML:
<form method="POST" name="form1" id="form1" action="<?php echo $editFormAction; ?>">
  <table id="personal" width="270" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr valign="baseline">
      <td height="40" valign="middle"><input name="strEmail" type="email" required class="campotexto" id="strEmail" placeholder="Correo electrónico - [email protected]" value="" size="40"></td>
    </tr>
    <tr valign="baseline">
      <td height="40" valign="middle"><input name="strEmail2" type="email" required class="campotexto" id="strEmail2" placeholder="Confirma correo electrónico" value="" size="40"></td>
    </tr>
    <tr valign="baseline">
      <td height="40" valign="middle">
        <input class="campotexto" type="text" name="strNombre"  size="40" required placeholder="Nombres" title="Ingrese su nombre" pattern="[A-Za-z\w\S\W]+" />
      </td>
    </tr>
    <tr valign="baseline">
      <td height="40" valign="middle">
        <input name="strApellido1" type="text" class="campotexto" id="strApellido1" size="40" placeholder="Primer apellido" required title="Ingrese su primer apellido" pattern="[A-Za-z\w\S\W]+" >
      </td>
    </tr>
    <tr valign="baseline">
      <td height="40" valign="middle">
        <input name="strApellido2" type="text" class="campotexto" id="strApellido2" size="40" placeholder="Segundo apellido" required title="Ingrese su segundo apellido" pattern="[A-Za-z\w\S\W]+">
      </td>
    </tr>
    <tr valign="baseline">
      <td height="40" valign="middle"><table width="250" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td><strong>Tipo documento:</strong></td>
          <td><input name="intTipoDocumento"  type="radio" value="1" required >
            C.C</td>
          <td><input type="radio" name="intTipoDocumento" value="2" required>
            C.E</td>
          </tr>
      </table></td>
    </tr>
    <tr valign="baseline">
      <td height="40" valign="middle">
        <input class="campotexto" name="strDocumento" type="text" size="25"  maxlength="11" required placeholder="No documento" pattern="[0-9]{8,11}" title="Números sin puntos, comas o guión, Mínimo 8 caracteres.">
      </td>
    </tr>
    <tr valign="baseline">
      <td height="40" valign="middle">
        
        <input name="strPassword" type="password" class="campotexto" id="strPassword" size="25" maxlength="20" required title="
Requisitos mínimos: 
6 caracteres, una mayúscula y una minúscula.
Puede usar caracteres especiales (*/.}{¿'=, etc..).
No use espacios en blanco." pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w\S{6,}" placeholder="Contraseña">
      </td>
    </tr>
    <tr valign="baseline">
      <td height="40" valign="middle">
        <input name="strPassword2" type="password" class="campotexto" id="strPassword2" size="25" maxlength="20" required title="
Requisitos mínimos: 
6 caracteres, una mayúscula y una minúscula.
Puede usar caracteres especiales (*/.}{¿'=, etc..).
No use espacios en blanco." pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w\S{6,}" placeholder="Confirme contraseña">
        
        
      </td>
    </tr>
    <tr valign="baseline">
      <td height="40" valign="middle"><table width="250" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td><strong>Sexo:</strong></td>
          <td><input type="radio" name="intSexo" value="1" required >
            Hombre</td>
          <td><input name="intSexo" type="radio" value="2" required >
            Mujer</td>
          </tr>
      </table></td>
    </tr>
    <tr valign="baseline">
      <td height="40" valign="middle">
        <input class="campotexto" type="text" name="strOcupacion" value="" size="40" required placeholder="Profesión u ocupación" id="strOcupacion">
      </td>
    </tr>
    <tr valign="baseline">
      <td height="40" valign="middle">
        <input name="strDireccion" type="text" class="campotexto" value="" size="40" required placeholder="Dirección de contacto y envio" id="strDireccion">
      </td>
    </tr>
    <tr valign="baseline">
      <td height="80" valign="middle"><table width="270" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="30" colspan="2"><strong>Teléfono de contacto:</strong></td>
          </tr>
        <tr>
      <td><input name="strTelFijo" type="text" class="campotexto" id="strTelFijo" size="15" maxlength="10" required placeholder="Fijo" pattern="[0-9]{7,10}" title="Números sin puntos ni comas, Mínimo 7 caracteres."></td>
      <td><input name="strCel" type="text" class="campotexto" id="strCel" size="15" maxlength="10" required placeholder="Celular" pattern="[0-9]{10,}" title="Números sin puntos ni comas, Mínimo 10 caracteres." ></td>
    </tr>
</table>
      </td>
    </tr>
    <tr valign="baseline" id="intDepartamento">
      <td height="40" valign="middle"><span id="spryselect1">
        <select  name="intDepartamento"  id="intDepartamento" class="camposeleccion" onChange="from(document.form1.intDepartamento.value,'intCiudad','includes/ciudad.php')">
          <option value="0">Departamento</option>
          <?php
do { 
?>
          <option value="<?php echo $row_Departamento['idDepartamento']?>"><?php echo $row_Departamento['strNombre']?></option>
          <?php
} while ($row_Departamento = mysql_fetch_assoc($Departamento));
  $rows = mysql_num_rows($Departamento);
  if($rows > 0) {
      mysql_data_seek($Departamento, 0);
	  $row_Departamento = mysql_fetch_assoc($Departamento);
  }
?>
          </select>
        <br>
        <span class="selectInvalidMsg">Seleccione departamento.</span></span></td>
    </tr>
    <tr valign="baseline" id="intCiudad">
      <td height="0" valign="middle"><span id="spryselect2">
        <select name="intCiudad"  id="intCiudad" class="camposeleccion">
          <option value="0">Ciudad</option>
          <?php 
do {  
?>
          <option value="<?php echo $row_Ciudad['idCiudad']?>"><?php echo $row_Ciudad['strNombre']?></option>
          <?php
} while ($row_Ciudad = mysql_fetch_assoc($Ciudad));
  $rows = mysql_num_rows($Ciudad);
  if($rows > 0) {
      mysql_data_seek($Ciudad, 0);
	  $row_Ciudad = mysql_fetch_assoc($Ciudad);
  }
?>
          </select>
        <br>
        <span class="selectInvalidMsg">Seleccione Ciudad.</span></span></td>
    </tr>
    <tr valign="baseline">
      <td height="80" valign="middle"><table width="280" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="30" colspan="3"><strong>Fecha de nacimiento:</strong></td>
              </tr>
            <tr>
            <td><span id="spryselect3">
          <select class="camposeleccion2" name="intDia" id="intDia">
            <option value="0">Día</option>
            <?php
do {  
?>
            <option value="<?php echo $row_Dia['idDia']?>"><?php echo $row_Dia['strNombre']?></option>
            <?php
} while ($row_Dia = mysql_fetch_assoc($Dia));
  $rows = mysql_num_rows($Dia);
  if($rows > 0) {
      mysql_data_seek($Dia, 0);
	  $row_Dia = mysql_fetch_assoc($Dia);
  }
?>
            </select>
          <span class="selectInvalidMsg">Seleccione día.</span></span></td>
            <td><span id="spryselect4">
            <select class="camposeleccion2" name="intMes" id="intMes">
              <option value="0">Mes</option>
              <?php
do {  
?>
              <option value="<?php echo $row_Mes['idMes']?>"><?php echo $row_Mes['strNombre']?></option>
              <?php
} while ($row_Mes = mysql_fetch_assoc($Mes));
  $rows = mysql_num_rows($Mes);
  if($rows > 0) {
      mysql_data_seek($Mes, 0);
	  $row_Mes = mysql_fetch_assoc($Mes);
  }
?>
              </select>
            <span class="selectInvalidMsg">Seleccione Mes.</span></span></td>
            <td><input class="campotexto" name="strAno" type="text" id="strAno" size="4" maxlength="4" required  pattern="[0-9]{4,}" title="Números sin puntos ni comas, Mínimo 4 caracteres." placeholder="Año"></td>
          </tr>
      </table>
      </td>
    </tr>
    <tr valign="baseline">
      <td height="60" align="center" valign="middle" nowrap><input class="boton" type="submit" name="submit" value="Registrar" onClick="return ComparaPersona(this);"></td>
    </tr>
  </table>
       <input type="hidden" name="intEstado" value="0">
        <input type="hidden" name="strActivar" value="<?php echo $activar?>">

  <input type="hidden" name="MM_insert" value="form1">
    </form
Aclaro que no soy programador, solo quiero hacer mi web.


Gracias por tu ayuda y por el tiempo en responder mi inquietud.
  #4 (permalink)  
Antiguo 01/12/2014, 16:48
Avatar de geovannimendoza  
Fecha de Ingreso: noviembre-2013
Mensajes: 15
Antigüedad: 10 años, 5 meses
Puntos: 0
Pregunta Respuesta: Activar cuenta enviando un mail

Ya lo solucioné, para que me tomara los datos, al realizar insertar la información a la base de datos, fue utilizar
Código PHP:
mysql_insert_id() 
y darle un nombre como variable de sesión, de esta manera me pasa el id del último registro y tomo los datos para enviar el mail para su posterior activación.

Etiquetas: enviando, formulario, html, mail, mysql, registro, select, sql
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 06:07.