Ver Mensaje Individual
  #2 (permalink)  
Antiguo 16/11/2010, 13:58
Avatar de shaggyz
shaggyz
 
Fecha de Ingreso: mayo-2008
Mensajes: 43
Antigüedad: 16 años
Puntos: 3
Respuesta: Ayuda codigo php

Buenas,

Código PHP:
<?php

$errors 
= array();

if(isset(
$_POST['login'])){

    
$username preg_replace('/[^A-Za-z]/'''$_POST['username']);
    
$email $_POST['email'];
    
$password $_POST['password'];
    
$c_password $_POST['c_password'];

    if(
$username == ''){
        
$errors[] = 'Username is blank';
    }
    if(
$email == ''){
        
$errors[] = 'Email is blank';
    }
    if(
$password == '' || $c_password == ''){
        
$errors[] = 'Passwords are blank';
    }
    if(
$password != $c_password){
        
$errors[] = 'Passwords do not match';
    }

    if(
count($errors) == 0){
        
        
// Esto antes estaba así, se instancia el objeto xml luego de que lo llamas, te tiene que dar un error o al menos un warning
        //$xml->addChild('username', $username);
        //$xml = new SimpleXMLElement('<user></user>');
        
        // Se instancia el objeto
        
$xml = new SimpleXMLElement('<user></user>');
        
        
// Se llama a addchild
        
$xml->addChild('username'$username);
        
        
$xml->addChild('password'md5($password));
        
$xml->addChild('email'$email);

        
$xml->asXML('archivo.xml');
        
header('Location: login.php');
        die;
        
    }
    
}
?>
Espero haberte ayudado