Comunidad de diseño web y desarrollo en internet online

ayuda necesaria

Citar            
MensajeEscrito el 11 Jun 2008 02:12 pm
Hola amigos!

Trabajé con dos archivos para para un sistema de usuarios lo que no puedo hacer es que cuando alguien se registra me llegue un coreo. Les dejo los archivos:

Register-form.php

Código :

<?php
   if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) {
      echo '<ul class="err">';
      foreach($_SESSION['ERRMSG_ARR'] as $msg) {
         echo '<li>',$msg,'</li>'; 
      }
      echo '</ul>';
      unset($_SESSION['ERRMSG_ARR']);
   }
?>
<form id="loginForm" name="loginForm" method="post" action="register-exec.php">
  <table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
    <tr>
      <th>Name </th>
      <td><input name="name" type="text" class="textfield" id="name" /></td>
    </tr>
    <tr>
      <th>Phone Number </th>
      <td><input name="phone" type="text" class="textfield" id="phone" /></td>
    </tr>
    <tr>
      <th>Email </th>
      <td><input name="email" type="text" class="textfield" id="email" /></td>
    </tr>
    <tr>
      <th>Company Name </th>
      <td><input name="compay" type="text" class="textfield" id="compay" /></td>
    </tr>
    <tr>
      <th>Fax Number </th>
      <td><input name="fa" type="text" class="textfield" id="fa" /></td>
    </tr>
    <tr>
      <th>Title </th>
      <td><input name="auno" type="text" class="textfield" id="auno" /></td>
    </tr>
    <tr>
      <th>Address </th>
      <td><input name="bdos" type="text" class="textfield" id="bdos" /></td>
    </tr>
    <tr>
      <th width="124">Login</th>
      <td width="168"><input name="login" type="text" class="textfield" id="login" /></td>
    </tr>
    <tr>
      <th>Password</th>
      <td><input name="password" type="password" class="textfield" id="password" /></td>
    </tr>
    <tr>
      <th>Confirm Password </th>
      <td><input name="cpassword" type="password" class="textfield" id="cpassword" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit" value="Register" /></td>
    </tr>
  </table>
</form>


y...

register-exec.php

Código :

<?php
   //Start session
   session_start();
   
   //Array to store validation errors
   $errmsg_arr = array();
   
   //Validation error flag
   $errflag = false;
   
   //Connect to mysql server
   $link = mysql_connect("localhost","cocinaco_nueva","nueva");
   if(!$link) {
      die('Failed to connect to server: ' . mysql_error());
   }
   //Select database
   $db = mysql_select_db("cocinaco_NUEVA");
   if(!$db) {
      die("Unable to select database");
   }
   
   //Function to sanitize values received from the form. Prevents SQL injection
   function clean($str) {
      $str = @trim($str);
      if(get_magic_quotes_gpc()) {
         $str = stripslashes($str);
      }
      return mysql_real_escape_string($str);
   }
   
   //Sanitize the POST values
   $name = clean($_POST['name']);
   $phone = clean($_POST['phone']);
   $email = clean($_POST['email']);
   $compay = clean($_POST['compay']);
   $fa = clean($_POST['fa']);
   $auno = clean($_POST['auno']);
   $bdos = clean($_POST['bdos']);
   $login = clean($_POST['login']);
   $password = clean($_POST['password']);
   $cpassword = clean($_POST['cpassword']);
   
   //Input Validations
   if($name == '') {
      $errmsg_arr[] = 'Name missing';
      $errflag = true;
   }
   if($phone == '') {
      $errmsg_arr[] = 'Phone missing';
      $errflag = true;
   }
   if($email == '') {
      $errmsg_arr[] = 'Email missing';
      $errflag = true;
   }
   if($compay == '') {
      $errmsg_arr[] = 'Company missing';
      $errflag = true;
   }
   if($fa == '') {
      $errmsg_arr[] = 'Fax missing';
      $errflag = true;
   }
   if($auno == '') {
      $errmsg_arr[] = 'Title missing';
      $errflag = true;
   }
   if($bdos == '') {
      $errmsg_arr[] = 'Address missing';
      $errflag = true;
   }
   if($login == '') {
      $errmsg_arr[] = 'Login ID missing';
      $errflag = true;
   }
   if($password == '') {
      $errmsg_arr[] = 'Password missing';
      $errflag = true;
   }
   if($cpassword == '') {
      $errmsg_arr[] = 'Confirm password missing';
      $errflag = true;
   }
   if( strcmp($password, $cpassword) != 0 ) {
      $errmsg_arr[] = 'Passwords do not match';
      $errflag = true;
   }
   
   //Check for duplicate login ID
   $qry = "SELECT count(*) AS c FROM members WHERE login='$login'";
   $result = mysql_query($qry);
   if($result) {
      $result_array = mysql_fetch_assoc($result);
      if($result_array['c'] > 0) {
         $errmsg_arr[] = 'Login ID already in use';
         $errflag = true;
      }
      @mysql_free_result($result);
   }
   else {
      die("Query failed");
   }
   
   //If there are input validations, redirect back to the registration form
   if($errflag) {
      $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
      session_write_close();
      header("location: register-form.php");
      exit();
   }

   //Create INSERT query
   $qry = "INSERT INTO members(name, phone, email, compay, fa, auno, bdos, login, passwd) VALUES('$name','$phone','$email','$compay','$fa','$auno','$bdos','$login','".md5($_POST['password'])."')";
   $result = mysql_query($qry);
   //Check whether the query was successful or not
   if($result) {
      header("location: register-success.php");
      exit();
   }else {
      die("Query failed");
   }
   

?>

Por bizarrismo

9 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 11 Jun 2008 02:29 pm
Hola bizarrismo te explico justo después que los datos son registrados utiliza la función mail()

Ejemplo

Código :

$qry = "INSERT INTO members(name, phone, email, compay, fa, auno, bdos, login, passwd) VALUES('$name','$phone','$email','$compay','$fa','$auno','$bdos','$login','".md5($_POST['password'])."')";
   $result = mysql_query($qry);
   //Check whether the query was successful or not
   if($result) {

      mail(tu_direccion@tu_dominio.com, tu_asunto, tu_mensaje)

      header("location: register-success.php");
      exit();
   }else {
      die("Query failed");
   }


espero que esto ayude saludos :D

Por Zis

Claber

314 de clabLevel

1 tutorial

Genero:Masculino  

Bell Ville - Cordoba - Argentina

firefox
Citar            
MensajeEscrito el 11 Jun 2008 03:06 pm
Es mucho mejor utilizar el paquete PHPMailer ademas que es mas sencillo de usar y esta bastante probado

Aparte de administrar las opciones con el mail nativo de PHP puedes usar una cuenta SMTP, MIME, hasta de google PHPMAILER

Por jpcw

Claber

1715 de clabLevel

1 tutorial

Genero:Masculino  

AlgoritmicBrainDesigner

firefox
Citar            
MensajeEscrito el 11 Jun 2008 03:54 pm

Zis escribió:

Hola bizarrismo te explico justo después que los datos son registrados utiliza la función mail()

Ejemplo

Código :

$qry = "INSERT INTO members(name, phone, email, compay, fa, auno, bdos, login, passwd) VALUES('$name','$phone','$email','$compay','$fa','$auno','$bdos','$login','".md5($_POST['password'])."')";
   $result = mysql_query($qry);
   //Check whether the query was successful or not
   if($result) {

      mail(tu_direccion@tu_dominio.com, tu_asunto, tu_mensaje)

      header("location: register-success.php");
      exit();
   }else {
      die("Query failed");
   }


espero que esto ayude saludos :D



creo que no jala...
mira...

Parse error: syntax error, unexpected '@' in /home/cocinaco/public_html/modeling/login/register-exec.php on line 117

Por bizarrismo

9 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 11 Jun 2008 03:59 pm

jpcw escribió:

Es mucho mejor utilizar el paquete PHPMailer ademas que es mas sencillo de usar y esta bastante probado

Aparte de administrar las opciones con el mail nativo de PHP puedes usar una cuenta SMTP, MIME, hasta de google PHPMAILER


Disculpa, de que manera pueda integrar el PHPMailer en mi código?

Por bizarrismo

9 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 11 Jun 2008 05:04 pm
aqui tienes como integrar phpmailer a tu codigo

http://blog.unijimpe.net/introduccion-a-phpmailer/

con respecto al error anterior me falto poner comillas

Código :

mail('tu_direccion@tu_dominio.com', 'tu_asunto', 'tu_mensaje')


saludos

Por Zis

Claber

314 de clabLevel

1 tutorial

Genero:Masculino  

Bell Ville - Cordoba - Argentina

firefox
Citar            
MensajeEscrito el 11 Jun 2008 06:28 pm

Zis escribió:

aqui tienes como integrar phpmailer a tu codigo

http://blog.unijimpe.net/introduccion-a-phpmailer/

con respecto al error anterior me falto poner comillas

Código :

mail('tu_direccion@tu_dominio.com', 'tu_asunto', 'tu_mensaje')


saludos


Gracias! El punto es.. que no me llega el correo... ni en correos deseados =S

Por bizarrismo

9 de clabLevel



Genero:Masculino  

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.