Ver Mensaje Individual
  #13 (permalink)  
Antiguo 05/07/2006, 03:42
Avatar de Javiglez
Javiglez
 
Fecha de Ingreso: marzo-2006
Ubicación: Valladolid
Mensajes: 496
Antigüedad: 18 años, 2 meses
Puntos: 0
voy a postear la clase a donde mando el formulario para que lo procese que se llama procesar.php por el metodo POST.

<!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>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

</head>
<body>


<?php


include("../conectarse_bd.php");
$link=Conectarse();



function comprobar_email($email){
$mail_correcto = 0;
if ((strlen($email) >= 6) && (substr_count($email,"@") == 1) && (substr($email,0,1) != "@") && (substr($email,strlen($email)-1,1) != "@")){

if ((!strstr($email,"'")) && (!strstr($email,"\"")) && (!strstr($email,"\\")) && (!strstr($email,"\$")) && (!strstr($email," "))) {

if (substr_count($email,".")>= 1){
$term_dom = substr(strrchr ($email, '.'),1);
if (strlen($term_dom)>1 && strlen($term_dom)<5 && (!strstr($term_dom,"@")) ){
$antes_dom = substr($email,0,strlen($email) - strlen($term_dom) - 1);
$caracter_ult = substr($antes_dom,strlen($antes_dom)-1,1);
if ($caracter_ult != "@" && $caracter_ult != "."){
$mail_correcto = 1;

}
}
}
}
}
if ($mail_correcto)
return 1;
else
return 0;
}



function quitar($mensaje)
{

$mensaje = str_replace("<","&lt;",$mensaje);
$mensaje = str_replace(">","&gt;",$mensaje);
$mensaje = str_replace("\'","'",$mensaje);
$mensaje = str_replace('\"',"&quot;",$mensaje);
$mensaje = str_replace("\\\\","\",$mensaje);
return $mensaje;
}

//FUNCION PARA ASEGURAR LA VALIDEZ DE UN DNI FACILITADO
function validadni ($dni) {
$nif=substr ($dni, 0, 8)+0;
$letra=strtoupper (substr ($dni, -1));
$letranif_array=array ("T","R","W","A","G","M","Y","F","P","D","X","B"," N","J","Z","S","Q","V","H","L","C","K","E","F") ;
$resto=$nif%23;
if ($letra==$letranif_array[$resto] && $nif!=0){
return true;
}else{
return false;
}
}
if (!isset ($_POST['dni']) || trim($_POST['dni'])=="" || !validadni($_POST['dni'])) {
header("Location: dni.php");
exit;
}







if((comprobar_email($mail)==1) ) {
echo "mail";


if(trim($HTTP_POST_VARS["pass"])!= trim($HTTP_POST_VARS["pass2"])){

header("Location: error_campos_cliente.php");
echo"la contraseña no esta bien puesta";
}
else{



$sql = "SELECT login FROM clientes WHERE login='".quitar($HTTP_POST_VARS["login"])."'";
$result = mysql_query($sql);

if($row = mysql_fetch_array($result))
{
header("Location: login_rep.html");

}
else
{

$sql = "INSERT INTO clientes (login,pass,pass2,nombre,apellido1,apellido2,mail, direccion,telefono,dni)
VALUES (";
$sql .= "'".quitar($HTTP_POST_VARS["login"])."'";
$sql .= ",'".quitar($HTTP_POST_VARS["pass"])."'";
$sql .= ",'".quitar($HTTP_POST_VARS["pass2"])."'";
$sql .= ",'".quitar($HTTP_POST_VARS["nombre"])."'";
$sql .= ",'".quitar($HTTP_POST_VARS["apellido1"])."'";
$sql .= ",'".quitar($HTTP_POST_VARS["apellido2"])."'";
$sql .= ",'".quitar($HTTP_POST_VARS["mail"])."'";
$sql .= ",'".quitar($HTTP_POST_VARS["direccion"])."'";
$sql .= ",'".quitar($HTTP_POST_VARS["telefono"])."'";
$sql .= ",'".quitar($HTTP_POST_VARS["dni"])."'";
$sql .= ")";
mysql_query($sql);

header("Location: listado_clientes.php");
}
mysql_free_result($result);
}
}

else
{
header("Location: mail.php");
echo "error";
}

mysql_close();
?>

</body>
<!---------------------------------------------------------------------------------------------------->


</html>