(Aug 17, 2014 03:51 PM)AppleJuice Wrote: There's no need to be throwing a hissy fit on HF. If you don't like someone, then you should get off the internet or ignore them.
I do think that it's nice you are creating a "tutorial" for people who would like to create a login/registration system, although I would suggest you to improve your tutorial and code a bit. There seems to be a lot of code that doesn't follow any standards. You should also improve your tutorial to explain a bit more what is happening and such. A lot of your code can be improved to make more sense.
For example, why are you unsetting $warning when it hasn't been set?
PHP Code
<?php
default: //there is no warning
//$warning = "none";
unset($warning);
break;
Seems like your database is extending PDO and then it creates a new PDO class? An it seems like your database class doesn't even use prepared statements as you said it did?
Directly using $username without sanitization? Nope!
PHP Code
<?php
$query = $con->runQuery("SELECT * FROM `users` WHERE `username`='".$username."'");
Of all of the years I've been programming, this made me wat all over the place.
PHP Code
<?php
$length = new stdClass();
$length->min = 4;
$length->max = 10;
$length->username = strlen($username);
if($length->username >= $length->min && $length->username <= $length->max){
return ctype_alnum($username);
}else{
return false;
}
You could just do
PHP Code
<?php
return (strlen($username) >= 4 && strlen($username) <= 10 && ctype_alnum($username));
I don't want to be a bashful asshole, I just want to help you out. If you're going to make a tutorial, I would suggest you to improve your code to make more sense a bit, and stick to standards.
You shouldn't teach people shit code.
Edit:
Just want to know, why use a maximum password length? I use password that are longer than 20 characters. And why restrict the password? If you're going to hash/encrypt it, why does it matter on the length or what the characters are? I'm sure others use long passwords with complex and special characters.
PHP Code
<?php
public function check_password($password){
$length = new stdClass();
$length->min = 6;
$length->max = 20;
$regex = '/^[a-zA-Z0-9 \!\@\#\$\%\^\&\*]{'.$length->min.','.$length->max.'}$/';
if(preg_match($regex, $password)){
return true;
}else{
return false;
}
}
Code
There's no need to be throwing a hissy fit on HF. If you don't like someone, then you should get off the internet or ignore them.
if that bitch please guy keeps posting low quality shit ye I start swearing at that kid.
read his previous posts, it doesn't give tips.
Code
Seems like your database is extending PDO and then it creates a new PDO class? An it seems like your database class doesn't even use prepared statements as you said it did?
read part 1 of the tutorial there is a note in the intro you'd see were I got in the mistake.
Code
return (strlen($username) >= 4 && strlen($username) <= 10 && ctype_alnum($username));
this looks indeed shorter but not nicer for beginners
they don't like such codes because it's too long or confusing, I have been in it too while seeing stuff like this.
Code
You shouldn't teach people shit code.
that's your opinion
I heard from others it is fine in it's ways.
Code
Just want to know, why use a maximum password length? I use password that are longer than 20 characters. And why restrict the password? If you're going to hash/encrypt it, why does it matter on the length or what the characters are? I'm sure others use long passwords with complex and special characters
the 20chars maximum was only for the limitation as showing that it is possible.
as far as the limited character goes since we are using strip_tags();
it will cut out html special characters
as if we make sure we only allow !-@-#-$-%-^-&-* and a-Z 0-9 we make sure no special character has been inputted
the minimal password length should always be inserted but I do recommend to keep it limited to 255 characters as if a password isn't really longer than 255
thanks for your input.
Edit:
I am prety sure cathal reported my paste.
but I am not going into conclussions since I have no rights to do that with him even when he's a hater.
for the reporter:
it's fine that you have personal issue's, but leave my stuff alone.
I am in contact with pastebin to get you off from their servers since this is way to inappropriate.