Ver Mensaje Individual
  #13 (permalink)  
Antiguo 25/08/2011, 15:37
Avatar de jatg
jatg
 
Fecha de Ingreso: abril-2011
Ubicación: caracas
Mensajes: 152
Antigüedad: 13 años, 1 mes
Puntos: 15
Respuesta: Problema con localhost/phpmyadmin

continuamos

bien ahora creamos estos otros

confirm.php

Código PHP:
Ver original
  1. <?php
  2. require_once('db.php');
  3. include('functions.php');
  4.  
  5.     if($_GET['ID']!='' && numeric($_GET['ID'])==TRUE && strlen($_GET['key'])==32 && alpha_numeric($_GET['key'])==TRUE)
  6.     {
  7.  
  8.         $query = mysql_query("SELECT ID, Random_key, Active FROM users WHERE ID = '".mysql_real_escape_string($_GET['ID'])."'");
  9.  
  10.         if(mysql_num_rows($query)==1)
  11.         {
  12.             $row = mysql_fetch_assoc($query);
  13.             if($row['Active']==1)
  14.             {
  15.                 echo "&error=".$error = 'This member is already active !';
  16.             }
  17.             elseif($row['Random_key']!=$_GET['key'])
  18.             {
  19.                 echo "&error=".$error = 'The confirmation key that was generated for this member does not match with the one entered !';
  20.             }
  21.             else
  22.             {
  23.                 $update = mysql_query("UPDATE users SET Active=1 WHERE ID='".mysql_real_escape_string($row['ID'])."'") or die(mysql_error());
  24.                 $msg = 'Congratulations !  You just confirmed your membership !';
  25.             }
  26.         }
  27.         else {
  28.  
  29.             echo "&error=".$error = 'User not found !';
  30.  
  31.         }
  32.  
  33.     }
  34.     else {
  35.  
  36.         $error = 'Invalid data provided !';
  37.  
  38.     }
  39.  
  40.     if(isset($error))
  41.     {
  42.         echo "&error=".$error;
  43.     }
  44.     else {
  45.         echo "&msg=".$msg;
  46.     }
  47. ?>


este otro

confirm_password.php

Código PHP:
Ver original
  1. <?php
  2. require_once('db.php');
  3. include('functions.php');
  4.  
  5.     $query = mysql_query("SELECT * FROM users WHERE ID = '".mysql_real_escape_string($_GET['ID'])."'");
  6.  
  7.     if(mysql_num_rows($query)==1)
  8.     {
  9.         $row = mysql_fetch_assoc($query);
  10.         if($row['Temp_pass']==$_GET['new'] && $row['Temp_pass_active']==1)
  11.         {
  12.             $update = mysql_query("UPDATE users SET Pass = '".md5(mysql_real_escape_string($_GET['new']))."', Temp_pass_active=0 WHERE ID = '".mysql_real_escape_string($_GET['ID'])."'");
  13.             $msg = 'Your new password has been confirmed. You may login using it.';
  14.         }
  15.         else
  16.         {
  17.             $error = 'The new password is already confirmed or is incorrect';
  18.         }
  19.     }
  20.     else {
  21.         $error = 'You are trying to confirm a new password for an unexisting member';
  22.     }
  23.  
  24.     if(isset($error))
  25.     {
  26.         echo $error;
  27.     }
  28.     else {
  29.         echo $msg;
  30.     }
  31. ?>

ahora este otro

functions.php

Código PHP:
Ver original
  1. <?php
  2.     function checkLogin($levels)
  3.     {
  4.         if(!$_SESSION['logged_in'])
  5.         {
  6.             $access = FALSE;
  7.         }
  8.         else {
  9.             $kt = split(' ', $levels);
  10.  
  11.             $query = mysql_query('SELECT Level_access FROM users WHERE ID = "'.mysql_real_escape_string($_SESSION['user_id']).'"');
  12.             $row = mysql_fetch_assoc($query);
  13.  
  14.             $access = FALSE;
  15.  
  16.             while(list($key,$val)=each($kt))
  17.             {
  18.                 if($val==$row['Level_access'])
  19.                 {//if the user level matches one of the allowed levels
  20.                     $access = TRUE;
  21.                 }
  22.             }
  23.         }
  24.         if($access==FALSE)
  25.         {
  26.             header("Location: login.php");
  27.         }
  28.         else {
  29.         //do nothing: continue
  30.         }
  31.  
  32.     }
  33.  
  34.     function valid_email($str)
  35.     {
  36.         return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
  37.     }
  38.  
  39.     function checkUnique($field, $compared)
  40.     {
  41.         $query = mysql_query("SELECT `".mysql_real_escape_string($field)."` FROM `users` WHERE `".mysql_real_escape_string($field)."` = '".mysql_real_escape_string($compared)."'");
  42.         if(mysql_num_rows($query)==0)
  43.         {
  44.             return TRUE;
  45.         }
  46.         else {
  47.             return FALSE;
  48.         }
  49.     }
  50.  
  51.     function numeric($str)
  52.     {
  53.         return ( ! ereg("^[0-9\.]+$", $str)) ? FALSE : TRUE;
  54.     }
  55.  
  56.     function alpha_numeric($str)
  57.     {
  58.         return ( ! preg_match("/^([-a-z0-9])+$/i", $str)) ? FALSE : TRUE;
  59.     }
  60.  
  61.     function random_string($type = 'alnum', $len = 8)
  62.     {
  63.         switch($type)
  64.         {
  65.             case 'alnum'    :
  66.             case 'numeric'  :
  67.             case 'nozero'   :
  68.  
  69.                     switch ($type)
  70.                     {
  71.                         case 'alnum'    :   $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  72.                             break;
  73.                         case 'numeric'  :   $pool = '0123456789';
  74.                             break;
  75.                         case 'nozero'   :   $pool = '123456789';
  76.                             break;
  77.                     }
  78.  
  79.                     $str = '';
  80.                     for ($i=0; $i < $len; $i++)
  81.                     {
  82.                         $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
  83.                     }
  84.                     return $str;
  85.               break;
  86.             case 'unique' : return md5(uniqid(mt_rand()));
  87.               break;
  88.         }
  89.     }
  90. ?>

y listo cualquiercosa pasate por mi foro

suerte

atte

ingeniero:jose alexis trujillo

caracas-venezuela
__________________
www.josealexis.net