Ver Mensaje Individual
  #3 (permalink)  
Antiguo 20/08/2010, 13:45
Avatar de truman_truman
truman_truman
 
Fecha de Ingreso: febrero-2010
Ubicación: /home/user
Mensajes: 1.341
Antigüedad: 14 años, 2 meses
Puntos: 177
Respuesta: Validar User y Email.

Hola por lo que veo usaste Dreamweaver para crear tu codigo:

Proba asi, lo modifiqué un poco

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


// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset(
$_POST[$MM_flag])) {
    
    
    
  
$MM_dupKeyRedirect="ya_existe.php";
  
  
$loginUsername $_POST['username'];
  
  
  
  
$LoginRS__query sprintf("SELECT username FROM usuarios WHERE username=%s"GetSQLValueString($loginUsername"text"));
  
mysql_select_db($database_server$server);
  
$LoginRS=mysql_query($LoginRS__query$server) 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;
  }
  
  
  
  
###########################################################
  ###########################################################
  ###########################################################
  ###########################################################
  
$loginEmail $_POST['email'];
  
$LoginRS__query2 sprintf("SELECT email FROM usuarios WHERE email=%s"GetSQLValueString($loginEmail"text"));
  
$LoginRS2=mysql_query($LoginRS__query2$server) or die(mysql_error());
  
$loginFoundUser2 mysql_num_rows($LoginRS2);

  
//if there is a row in the database, the username was found - can not add the requested username
  
if($loginFoundUser2){
    
$MM_qsChar "?";
    
//append the username to the redirect page
    
if (substr_count($MM_dupKeyRedirect,"?") >=1$MM_qsChar "&";
    
$MM_dupKeyRedirect $MM_dupKeyRedirect $MM_qsChar ."requsername=".$loginEmail;
    
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 usuarios (username, password, email, calle, no_int, no_ext, cp, col, del_mun, edo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['username'], "text"),
                       
GetSQLValueString($_POST['password'], "text"),
                       
GetSQLValueString($_POST['email'], "text"),
                       
GetSQLValueString($_POST['calle'], "text"),
                       
GetSQLValueString($_POST['no_int'], "int"),
                       
GetSQLValueString($_POST['no_ext'], "int"),
                       
GetSQLValueString($_POST['cp'], "int"),
                       
GetSQLValueString($_POST['col'], "text"),
                       
GetSQLValueString($_POST['del_mun'], "text"),
                       
GetSQLValueString($_POST['edo'], "text"));

  
mysql_select_db($database_server$server);
  
$Result1 mysql_query($insertSQL$server) or die(mysql_error());
}
?>
__________________
la la la