Ver Mensaje Individual
  #12 (permalink)  
Antiguo 07/07/2006, 13:11
Avatar de JAK^
JAK^
 
Fecha de Ingreso: octubre-2005
Ubicación: ^^CaMiNiTo Al CoSTaDo DeL
Mensajes: 850
Antigüedad: 18 años, 6 meses
Puntos: 4
bueno muchacos aka esta el code es para validar un formulario y si todo esta bien hace un update en una ddbb

Código PHP:

<?
include("login_.inc");
// validacion ============

    
$error=0;
    if (!
$_POST[apellido] or !is_string($_POST[apellido])) {
        
$error++;
        
$error_msg=$error.".- Error, Aplellido Invalido. <br>";
        
$_POST[apellido]="";
    }

    if (!
$_POST[nombres] or !is_string($_POST[nombres])) {
        
$error++;
        
$error_msg .=$error.".- Error, Nombres Invalidos. <br>";
        
$_POST[nombres]="";
    }
    if (!
$_POST[nick] or (strlen($_POST[nick])>10)) {
        
$error++;
        
$error_msg .=$error.".- Error, Nick Invalido. <br>";
        
$_POST[nick]="";
    }
    
$sql=mysql_query("select * from usuarios where nick = '$_POST[nick]'"$coneccion);
    
$sql_2=mysql_query("select * from usr_registrados where nick = '$_POST[nick]'"$coneccion);
    
    if (
mysql_num_rows($sql)>or mysql_num_rows($sql_2)>0) {
        
$error++;
        
$error_msg .=$error.".- Error, el Nick ya existe. <br>";
        
$_POST[nick]="";
    }
    
    if (!
$_POST[nsn] and !$_POST[yahoo]) {
        
$error++;
        
$error_msg .=$error.".- Error, tenes que tener una cuenta msn y/o yahoo. <br>";

    }
    
    if (!
$_POST[pass] or (strlen($_POST[pass])>10)) {
        
$error++;
        
$error_msg .=$error.".- Error, Pass Invalido. <br>";
        
$_POST[pass]="";
    }
    
    if (
$_POST[pass]<>$_POST[pass_confirm]) {
        
$error++;
        
$error_msg .=$error.".- Error, confirmacion de Pass no concuerda. <br>";
        
$_POST[pass]="";
        
$_POST[pass-confirm]="";
    }
    if (!
ereg("^([a-zA-Z0-9._]+)@([a-zA-Z0-9.-]+).([a-zA-Z]{2,4})$",$_POST[e_mail])){ 
        
$error++;
        
$error_msg .= "$error.- Error, e-mail invalido <br>";
        
$_POST[e_mail]="";
      } 
    
    
    if (!
$_POST[campo1]){
         
$error++;
        
$error_msg .= "$error.- Error, no pusiste nada en tu descripción. <br>";    
        
$_POST[campo1]="";
    }  


    
    
    if (
$error==0) {
    
    if (
$_POST[edad]<=15) {
        
$cod_sala=1;

    }elseif (
$_POST[edad]>15 and $_POST[edad]<=18){
        
$cod_sala=2;
    }else {
        
$cod_sala=3;
    }
    
    
$sql=mysql_query("update usr_registrados set  apellido='$_POST[apellido]', nombres='$_POST[nombres]', nick='$_POST[nick]', pass='$_POST[pass]', cumple_dia='$_POST[cumple_dia]', cumple_mes='$_POST[cumple_mes]', edad='$_POST[edad]', sexo='$_POST[sexo]', provincia='$_POST[provincia]', e_mail='$_POST[e_mail]', msn='$_POST[msn]', yahoo='$_POST[yahoo]', descrip='$_POST[campo1]', cod_sala='$cod_sala'"$coneccion);
    if (
mysql_error()) {
     
$error++;
        
$error_msg .= "$error.- Error, no se pudo cargar la info correctamente, por favor intentá nuevamente. <br>";
    }
    }
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Guardando...</title>
<style type="text/css">
<!--
body {
    background-color: #FF9900;
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
.Estilo3 {
    color: #FFFFFF;
    font-weight: bold;
}
body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    color: #333333;
    font-size: 12px;
}
.Estilo90 {    font-size: 12px;
    font-weight: bold;
    color: #000000;
}
-->
</style></head>

<body>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="760" height="100" bgcolor="#FF9900"><p>
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="760" height="100">
        <param name="movie" value="../title.swf" />
        <param name="quality" value="high" />
        <embed src="../title.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="760" height="100"></embed>
      </object>
    </p></td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#FFFFFF"><p>&nbsp;</p></td>
  </tr>
  <tr>
    <td align="center" valign="middle" bgcolor="#FFFFFF">
    <?
    
if ($error>0){ ?>
    <table width="95%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF9900">
      <tr>
        <td bgcolor="#FF9900"><div align="center"><span class="Estilo3">:: Error ::</span></div></td>
      </tr>
      <tr>
        <td height="16"><? 
        
        
        
echo $error_msg?></td>
      </tr>
      <tr>
        <td height="24" bgcolor="#FF9900"><form name="form1" method="post" action="modif_espacio.php">
          <div align="right">
            <? 
            
foreach( $_POST as $key => $value ) { 
                echo 
"<input type='hidden' name='".$key."' value='".$value."'>"
            } 
        
?>
            <input name="corregir" type="submit" class="Estilo90" id="corregir" value="volver y Corregir">
            </div>
        </form></td>
      </tr>
    </table>
    <p>
      <? } else {
/* Redireccionar a una pagina diferente en el directorio actual de la peticion */
$host  $_SERVER['HTTP_HOST'];
$uri  rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra 'index.php';
header("Location: http://$host$uri/$extra");
exit; 

?>
    <p>&nbsp;</p>
      </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </td>
  </tr>
  <tr>
    <td align="center" valign="middle" bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
</table>
</body>
el archivo login_.inc ke se incluye no kreo ke tenga errores puesto ke lo incluyo en todo el sitio y ningun problema....

perdon por las molestias ocacionadas...
__________________
hola . . .