 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
10-20-2008, 03:21 AM
|
#1 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
Need some help, and i have got some questions to ask as well.
So i will start of with saying thank you to everyone who has helped me before and who will help out, and i will try to help out as much as i can. So for the question part. i was thinking what is the best way to secure an account i mean password and so on.
like password salt?
and stuff like that, i am
still a bit fuzzy on the part where you secure the password.
So all the help i can get is really appreciated.
And then i would need some help on why this is not working
i get this
print "You're account was made!";
but noting appears in the db.
PHP Code:
<?php include 'config.php'; if(isset($_POST['submit'])) {
$username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; $referral = $_POST['referral'];
if(strlen($username)<1) { echo "You forgot to put in a username!"; } if(strlen($password)<1) { echo "You Forgot to put in a password!"; } if(strlen($email)<1) { echo "You did not put in you're email!"; } else { if(preg_match('/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/', $email)) { $query=( "INSERT INTO user (id, username,password,email,rank,referral,joined,ip) VALUES ('$id','$username',password('$password'),'$email','Normal','$referral',NOW(),'$ip')"); mysql_query($query) or die(mysql_error()); } else { print "You're account was made!"; } } } else { echo "<form action='register.php' method='post'>", "Please do mix, you're password with letters and numeric characters.</br>", "Username:", "<input type='text' name='username' size='15'/></br>", "Password:", "<input type='password' name='password' size='15'/></br>", "Email:", "<input type='text' name='email' size='15'/><br/>", "Referral:", "<input type='text' name='referral' size='15'/></br>", "<input type='submit' name='submit' value='submit'/></form>"; }
?>
Thank you in advance!
Code;Freek!

|
|
|
|
10-20-2008, 06:17 AM
|
#2 (permalink)
|
|
The Contributor
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
|
Hi cf,
your if-else block at the regex-thingy says: If the regex matches, do something in your Db, if not, output 'Your account was made'. I don't know if that is what you want your script to do.
Please filter your $_POST values, don't use them unfiltered in SQL statements. It's very dangerous( SQL-Injection).
Greetings,
Alex
|
|
|
10-20-2008, 11:17 AM
|
#3 (permalink)
|
|
The Addict
Join Date: Nov 2007
Location: USA
Posts: 256
Thanks: 7
|
A good thing for storing passwords is to encrypt them and to use a salt with that like you said. An example would be
Quote:
$salt = "Some short string here";
$password = md5( $salt . sha1($password));
|
So then when you create the account you would use this on the password before inserting it to the db, as well as when that user logs in. This way their password is always encrypted, providing more security.
|
|
|
|
|
The Following User Says Thank You to CoryMathews For This Useful Post:
|
|
10-20-2008, 01:59 PM
|
#4 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
awuehr, filter whit what?
|
|
|
|
10-20-2008, 02:09 PM
|
#5 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
You could try mysql_real_escape_string. Although if you wanted to take it further, you could filter depending on what you're expecting the data to be. Integer, string, et cetera...
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
|
The Following User Says Thank You to Wildhoney For This Useful Post:
|
|
10-20-2008, 02:43 PM
|
#6 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
i tried this but it wont work ? should i maybe do a check if the preg_match is valid by turning it into a var, and then running a check or how should i do it :S
Thank you!
PHP Code:
if(preg_match('/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/', $email)) { $query=( "INSERT INTO user (id, username,password,email,rank,referral,joined,ip) VALUES ('$id','$username',password('$password'),'$email','Normal','$referral',NOW(),'$ip')"); mysql_query($query) or die(mysql_error()); } else { echo 'Not a valid email!'; } else { echo 'Your account was made!'; } } } }
|
|
|
|
10-20-2008, 02:58 PM
|
#7 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
i tried this, but it wont input anything to the db :S
PHP Code:
if(preg_match('/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/', $email)) { $query=( "INSERT INTO user (id, username,password,email,rank,referral,joined,ip) VALUES ('$id','$username',password('$password'),'$email','Normal','$referral',NOW(),'$ip')"); mysql_query($query) or die(mysql_error()); print "your account was made!"; } else { echo 'not valid email!'; } } }
|
|
|
|
10-20-2008, 07:51 PM
|
#8 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
i made a new pattern but i get ? insted of @ ;/
help..
PHP Code:
/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*\@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/
|
|
|
|
10-20-2008, 10:07 PM
|
#9 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
omg, what a noob mistake ! ;P forgot to set a set on the db
working now thank you ;)
|
|
|
|
10-20-2008, 11:03 PM
|
#10 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
why do i get error on this ?
PHP Code:
$sql = printf(" INSERT INTO `users` SET `username` = '%s', `password` = '%s', `email` = '%s', `rank` = 'normal', `referral` = '%s', `joined` = NOW()",
mysql_real_escape_string($username), mysql_real_escape_string($password), mysql_real_escape_string($email), mysql_real_escape_string($referral));
|
|
|
|
10-20-2008, 11:11 PM
|
#11 (permalink)
|
|
The Addict
Join Date: Nov 2007
Location: USA
Posts: 256
Thanks: 7
|
using % instead of $ if those are variables.
|
|
|
|
10-20-2008, 11:27 PM
|
#12 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
don't follow :S
|
|
|
|
10-21-2008, 12:15 AM
|
#13 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
Fixed Thank you!
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|