Ver Mensaje Individual
  #4 (permalink)  
Antiguo 21/01/2010, 21:01
den_22
 
Fecha de Ingreso: enero-2010
Mensajes: 198
Antigüedad: 14 años, 10 meses
Puntos: 1
Respuesta: Ayuda con este código

Bueno muchas gracias, por contestar. Ahora tengo un pequeño problemita, corregí lo que me faltaba, pero en la ultima linea me tira "Parse error: parse error in C:\wamp\www\1.php on line 101"
Cual es el problema?, este archivo lo guardo con extensión php, pero tiene html dentro.
Aca está el codigo:

Código:
<?php
if (isset($_POST['submitted'])) {

    $errors = array ();
        require_once ('mysql_connect.php');
		}
		
		
		

if (eregi('^[[:alnum:]\.\'\-]{4,30}$', stripslashes(trim($_POST['username']))) ) {
    
    $user= mysql_real_escape_string($_POST['username']);
    $query="SELECT username FROM users WHERE username = '$user'";
    $result=@mysql_query($query);
    $num=@mysql_num_rows($result);

    
    if($num> 0) {
        $errors[] = '<font color="red">The username you have chosen has already been taken, please try again.</font>';
    } else {
        $username =mysql_real_escape_string($_POST['username']);
    }
  } else {
        $errors[]='<font color="red">Please provide a valid username between 4 and 30 characters.</font>';
        
        }


if (!eregi('^[a-zA-Z]+[a-zA-Z0-9_-]*@([a-zA-Z0-9]+){1}(\.[a-zA-Z0-9]+)
{1,2}', stripslashes(trim($_POST['email'])) )) {
        $errors[]= '<font color="red">Please provide a valid email adress.</font>';
        } else {
            $email=mysql_real_escape_string($_POST['email']);
        
        }

if(!empty($_POST['password1'])) {
    if($_POST['password1'] != $_POST['password2']){
        $errors[]='<font color="red">The 2 passwords you have entered do not match.</font>';
        } else {
            $password=$_POST['password1'];
        }
    } else {
        $errors[]='<font color ="red">Please provide a password.</font>';
    }


if(empty($errors)) {
            $a=md5(uniqid(rand(),true));
        $query="INSERT INTO users (username, email, password, active) VALUES ('$username','$email', SHA('$password'), '$a')";
        
        
        $result= @mysql_query($query);
        
        if(mysql_affected_rows()==1) {
        
                //Send the E-Mail
                
                $body="Thank you for registering at the User Registration Site.To activate your account, please click on this link:\n\n";
                $body.="http://www.whateveraddressyouwantthere.com/activate.php?x=" . mysql_insert_id() . "&y=$a";
                
                    mail($_POST['email'], 'Registration Confirmation', $body, 'From:[email protected]');
                    
                    
                        //Show thank message
                
                echo '<h3>Thank You!</h3>
                
                You have been registered, you have been sent an e-mail to the address you specified before.Please check your e-mails to activate your
account. ';
                } else {
                
                    echo '<font color="red">You could not be registered, please contact us about the problem and we will fix it as soon as we can.</font>';

    }
    ?>

<html>
<head>
</head>
<body>
<h3>Register</h3>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<p><input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" size="30" maxlenght="30" />
<small>Username</small></p>
<p><input type="password" name="password1" size="30" maxlenght="40" />
<small>Password</small></p>
<p><input type="password" name="password2" size="30" maxlenght="40" />
<small>Confirm Password</small></p>

<p><input type="text" name="email" size="30" maxlenght="30" value="<?php if(isset($_POST['mail'])) { echo $_POST['mail']; } ?>" /> <small> Email Address</small></p>

<p><input type="submit" name="submit" value="Register" /></p>
<input type="hidden" name="submitted" value="TRUE" />

</form>
</body>
</html>