Results 1 to 2 of 2
  1. #1

    Default Some help please..

    Hey, I'm working on my new site, I've just finished coding the register script. It keeps returning the no username or no password provided errors but when i check the vars they all match up, I've also checked my clean function that's wrapped round the post vars and it's not that causing the error either. Can anyone have a look at this i've been reading it over for about half an hour trying to find it with no luck.
    PHP Code:
    <?php

    if(isset($_POST['register']))
    {
        
    $user = clean($_POST['user']);
        
    $pass = clean($_POST['pass']);
        
    $cpass = clean($_POST['cpass']);
        
    $email = clean($_POST['email']);
        
        
    $errors = array();
        
        if(!
    $user)
        {
            
    $errors[] = "You did not specify a username";
        }
        
        if(!
    $pass)
        {
            
    $errors[] = "You did not specify a password.";
        }
        
        if(!
    $cpass)
        {
            
    $errors[] = "Please confirm your password.";
        }
        
        if(!
    $email)
        {
            
    $errors[] = "You did not specify an E-Mail address.";
        }
        
        if(
    $user)
        {
            
    $get = mysql_query("SELECT * FROM `users` WHERE `username` = '" . $user . "'");
            if(
    mysql_num_rows($get) > 0)
            {
                
    $errors[] = "That username is already in use. Please choose another one.";
            }
        }
        
        if(
    $pass)
        {
            if(
    strlen($pass) < 6)
            {
                
    $errors[] = "Your password is too short. Password must be atleast 6 characters.";
            }
        }
        
        if(
    $pass && $cpass)
        {
            if(
    $cpass != $pass)
            {
                
    $errors[] = "The 2 passwords you supplied do not match.";
            }
        }
        
        if(
    $email)
        {
            if(!
    eregi("^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*@[a-zA-Z0-9]+[a-zA-Z0-9_.-])*\.[a-z]{2,4}$", "$email"))
            {
                
    $errors[] = "Invalid E-Mail address.";
            }
        }
        
        if(
    count($errors) > 0)
        {
            echo(
    "<div class=\"heading\">Error..</div><p>");
            foreach(
    $errors as $error)
            {
                echo(
    "&raquo; " . $error . "<br />");
            }
            echo(
    "</p>");
        }
        else
        {
            
    $pass = md5($pass);
            
    mysql_query("INSERT INTO `users` (`username`, `password`, `email`) VALUES ('" . $user . "', '" . $pass . "', '" . $email . "')");
            echo(
    "<div class=\"heading\">Success..</div>
            <p>Congratualtions, you're successfully registered, you may now login.</p>"
    );
        }
    }
    else
    {
        echo(
    "<div class=\"heading\">Sign up</div>
        <p>By registering an account with us, you entitle yourself to a number of benefits not available to normal users. These include:</p>
        <p>&raquo; 10MB Upload maximum<br />
        &raquo; Your own folder to store your files<br />
        &raquo; 100MB Folder capacity<br />
        &raquo; Access to a user shoutbox<br /></p>
        <p>You can register an account by using the form below..<p>
        <p><form method=\"post\"><table width=\"350\">
        <tr><td width=\"150\">Username:</td><td width=\"200\"><input type=\"text\" name=\"user\" size=\"30\" /></td></tr>
        <tr><td>Password</td><td><input type=\"password\" name=\"pass\" size=\"30\" /></td></tr>
        <tr><td>Confirm</td><td><input type=\"password\" name=\"cpass\" size=\"30\" /></td></tr>
        <tr><td>E-Mail Address</td><td><input type=\"text\" name=\"email\" size=\"40\" /></td></tr>
        <tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"register\" value=\"Sign Up\" /></td></tr>
        </table>"
    );
    }
    ?>
    Thanks in advance.

  2. #2

    Default

    Sorry for double post, I couldn't edit my post. I've solved the problem now. Don't need help anymore

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •