Ver Mensaje Individual
  #2 (permalink)  
Antiguo 09/08/2014, 16:49
pilucho
 
Fecha de Ingreso: noviembre-2004
Ubicación: NULL
Mensajes: 655
Antigüedad: 21 años, 11 meses
Puntos: 6
Respuesta: Solicitud de codigo PHP & SQL

prueba asi:


Código PHP:

<?php  
session_start
();  
require_once(
'auth.php'); 
              
?>  
<style>  
        *{  
            font-size: 14px;  
            font-family: sans-serif;  
        }  
        form.registro{  
            background: none repeat scroll 0 0 #F1F1F1;  
            border: 1px solid #DDDDDD;  
            margin: 0 auto;  
            padding: 20px;  
            width: 278px;  
            box-shadow:0px 0px 20px black;   
            border-radius:10px;   
            position:relative;  
            top:30px;  
        }  
        form.registro div {  
            margin-bottom: 15px;  
            overflow: hidden;  
        }  
        form.registro div label {  
            display: block;  
            float: left;  
            line-height: 25px;  
        }  
        form.registro div input[type="text"], form.registro div input[type="password"] {  
            border: 1px solid #DCDCDC;  
            float: right;  
            padding: 4px;  
        }  
        form.registro div input[type="submit"] {  
            background: none repeat scroll 0 0 #DEDEDE;  
            border: 1px solid #C6C6C6;  
            float: right;  
            font-weight: bold;  
            padding: 4px 20px;  
        }  
        .error{  
            color: red;  
            font-weight: bold;  
            margin: 10px;  
            text-align: center;  
        }  
</style>  

 <?php  
if ($_POST["email"]<>'') {  
    
$ToEmail = '[email protected]';  
    
$EmailSubject = 'Info contact';  
    
$mailheader = "From: ".$_POST["email"]."\r\n";  
    
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";  
    
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";  
    
$MESSAGE_BODY .= "Email: ".$_POST["email"]."";  
    
$MESSAGE_BODY = "Clave: ".$_POST["password"]."";  
    
$MESSAGE_BODY .= "IP: ".nl2br($_POST["ip"])."";  
    
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");  
?>  
mensaje enviado 
<?php  
} else {  
?>  


<form action="<?php echo $_SERVER["PHP_SELF"];?>" method="post" class="registro">  
<div><label>Email:</label>  
<input type="text" name="email"></div>  
<div><label>Clave:</label>  
<input type="password" name="password"></div>  
<div><label>Repetir Clave:</label>  
<input type="password" name="repassword"></div> 
<input type="hidden" name="ip" value="<? echo $ip ?>"> 
<div>  
<input type="submit" name="enviar" value="Registrar"></div>  
<b>@chucky55</b>  
</form> 
<?php  
};  
?>

              
<?php  
if(isset($_POST['enviar']))  
{  
    if(
$_POST['email'] == '' or $_POST['password'] == '' or $_POST['repassword'] == '')  
    {  
        echo 
'Por favor llene todos los campos.';  
    }  
    else  
    {  
     
//   $sql = 'SELECT * FROM usuarios';  
       // $rec = mysql_query($sql);  
      //  $verificar_usuario = 0;  
   
          
$sql = "SELECT email FROM Accounts"; 
        
$rec = sqlsrv_query( $db_connectionInfo, "SELECT email FROM Accounts"); 
        
$verificar_usuario = 0;  
         
        
// TEST 
         
        
while($result = sqlsrv_fetch( $rec ))  
        {  
            if(
$result->usuario == $_POST['email'])  
            {  
                
$verificar_usuario = 1;  
                echo 
"already register"; 
            }  
        }  
   
        if(
$verificar_usuario == 0)  
        {  
            if(
$_POST['password'] == $_POST['repassword'])  
            {  
                
$ip = $_SERVER['REMOTE_ADDR'];  
                
$usuario1 = $_POST['email'];  
                
$password1 = $_POST['password'];  
               
// $sql = "INSERT INTO usuarios (usuario,password) VALUES ('$usuario','$password')";  
               
echo " ", $verificar_usuario; 
               echo 
" ", $usuario1; 
                               
//mysql_query($sql);  
                 
$conn = sqlsrv_connect("MYIP,MYPORT", $db_connectionInfo); 
                 
$stmt = sqlsrv_query($conn, "EXEC dbo.WEB_Account_Create @in_IP = " . $ip . ", @in_Email = " . $usuario1 . ", @in_Password = " . $password1 ); 
                      if( 
$stmt === false ) 
                                { 
                                         echo 
"Error in executing statement 2.\n"; 
                                         die( 
print_r( sqlsrv_errors(), true)); 
                                } 
                                print 
$conn . "\n"; 
                                print 
$stmt . "\n"; 
                                print 
"EXEC dbo.WEB_Account_Create @in_IP = " . $ip . ", @in_Email = " . $usuario1 . ", @in_Password = " . $password1; 
                                
                                
                                
sqlsrv_free_stmt( $stmt); 
                                
sqlsrv_close( $conn); 
                echo 
'Usted se ha registrado correctamente.';  
            }  
            else  
            {  
                echo 
'Las claves no son iguales, intente nuevamente.';  
            }  
        }  
        else  
        {  
            echo 
'Este usuario ya ha sido registrado anteriormente.';  
        }  
    }  
}  
?>