Jump to content

Simple login gone wrong?


Cory94bailly

Recommended Posts

I found this: http://www.ineedtutorials.com/articles/complete-advanced-login-member-system-php-tutorial and was trying to get it working..

 

(If anyone doesn't want to construct all that, I zipped it and uploaded it to: http://etsoldiers.com/simplelogin.zip)

 

Well problems I have with it are:

 

1.) No matter what you put into the register fields, it will say "Registration failed! Please try again."

2.) It puts info into mysql but still says failed.. Also, if I try to login with it.. it won't let me.

 

 

 

Any help? :)

Link to comment
Share on other sites

can you post your registration code.

 

Register.php:

 

<?php

require_once "header.php";

if (isset($_POST['register'])){
   
    if (registerNewUser($_POST['username'], $_POST['password'], $_POST['password2'], $_POST['email'])){
       
        echo "Thank you for registering, an email has been sent to your inbox, Please activate your account.
        <a href='./index.php'>Click here to login.</a>
        ";
       
    }else {
       
        echo "Registration failed! Please try again.";
        show_registration_form();
       
    }
   
} else {
// has not pressed the register button
    show_registration_form();   
}

require_once "footer.php";
?>

 

 

Validation.functions.inc.php:

 

<?php

#### Validation functions ####

function valid_email($email)
{

    // First, we check that there's one @ symbol, and that the lengths are right
    if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email))
    {
        // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
        return false;
    }
    // Split it into sections to make life easier
    $email_array = explode("@", $email);
    $local_array = explode(".", $email_array[0]);
    for ($i = 0; $i < sizeof($local_array); $i++)
    {
        if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
            $local_array[$i]))
        {
            return false;
        }
    }
    if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1]))
    { // Check if domain is IP. If not, it should be valid domain name
        $domain_array = explode(".", $email_array[1]);
        if (sizeof($domain_array) < 2)
        {
            return false; // Not enough parts to domain
        }
        for ($i = 0; $i < sizeof($domain_array); $i++)
        {
            if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i]))
            {
                return false;
            }
        }
    }
    return true;
}

function valid_username($username, $minlength = 3, $maxlength = 30)
{

    $username = trim($username);

    if (empty($username))
    {
        return false; // it was empty
    }
    if (strlen($username) > $maxlength)
    {
        return false; // to long
    }
    if (strlen($username) < $minlength)
    {

        return false; //toshort
    }

    $result = ereg("^[A-Za-z0-9_\-]+$", $username); //only A-Z, a-z and 0-9 are allowed

    if ($result)
    {
        return true; // ok no invalid chars
    } else
    {
        return false; //invalid chars found
    }

    return false;

}

function valid_password($pass, $minlength = 6, $maxlength = 15)
{
    $pass = trim($pass);

    if (empty($pass))
    {
        return false;
    }

    if (strlen($pass) < $minlength)
    {
        return false;
    }

    if (strlen($pass) > $maxlength)
    {
        return false;
    }

    $result = ereg("^[A-Za-z0-9_\-]+$", $pass);

    if ($result)
    {
        return true;
    } else
    {
        return false;
    }

    return false;

}

?>

 

 

 

If you need anymore codes, ask me :P

Link to comment
Share on other sites

by looking at the website you gave us, function registerNewUser is assigned to

function registerNewUser($username, $password, $password2, $email)
{

   global $seed;

   if (!valid_username($username) || !valid_password($password) ||
           !valid_email($email) || $password != $password2 || user_exists($username))
   {
       return false;
   }

Link to comment
Share on other sites

We don't feel like searching in the dark for a solution to YOUR problem.  Being a complete jerk will not get you far at all.

 

Well I'm sorry for asking.. How can I find the problem if idk what the code means?

 

How am I being a jerk? I gave a url and that guy didn't read it.

Link to comment
Share on other sites

"Seriously.. Are you blind?"

 

That's jerky.  Not the beef kind.  Anyway, I honestly think that it would be easier to write your own system so that it works how YOU want it to. =/  And honestly, I didn't click the link yet either.  I hate aimlessly reading (probably poorly designed, like most systems like that) code.

Link to comment
Share on other sites

Here:

 

1) list your problems(about the php, not your life). Its like surgery: If the doctor doesn't know whats going wrong, they can't fix it.

2) Do not use scripts you find on the web. Use those as a resource, not an option. The worst possible thing you could do for your website is to use pre-made scripts. Here's why:

    a) when you come across errors(like now), you'll have no idea where to find them.

    b) when you come across errors, you'll have to post the code every time here, and have us fix it. Its a LOT faster and easier to learn PHP your self then to wait for a response each time

    c) If you don't know what they script is doing and where, its very unsafe. For all you know, it might have it set up to alert the script creator when its being used, and email passwords, etc. Or maybe they purposefully left a security hole so they can come back to get in your site. Sounds crazy, buts its possible and HAS happened before.

 

3)I'm taking some of my valuable time to read your post and try to help. When  i could be working on my website and adding more features to it, increasing my revuenue. So you're probably flustered from reading this and ready to write a hate message back to me, but wait. Calm down, and realize that I am helping YOU... YOU need us to help you, WE don't HAVE to answer. We're not all going to get along, but either calm down, or stop expecting answers.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.