neenach2002
06-27-2004, 12:23 AM
I am trying to make a member system. There is something I can't seem to figure out. I'm trying to do it all 100% by hand.
How can I set the password to be MD5ed?
How can I set the password to be MD5ed?
|
Click to See Complete Forum and Search --> : Problems with first database... neenach2002 06-27-2004, 12:23 AM I am trying to make a member system. There is something I can't seem to figure out. I'm trying to do it all 100% by hand. How can I set the password to be MD5ed? AdamGundry 06-27-2004, 02:38 AM You need to call the md5 function on the password when you put it into the database, for example: mysql_query("INSERT INTO `tablename` (`password`, ...) VALUES (MD5('$password'), ...)"); Adam neenach2002 06-27-2004, 10:59 AM Just a little more detail would be nice...;) Where would I put that query/code? Nevermore 06-27-2004, 11:21 AM OK, I assume you have code like this: $password=$_POST['password']; $username=$_POST['username']; $query="INSERT INTO `member` (`username`,`password`) VALUES ('$username','$password')"; $results=mysql_query($query); The PHP function to MD5 encode a string is md5(), just declare it like: $password=md5($_POST['password']); $username=$_POST['username']; $query="INSERT INTO `member` (`username`,`password`) VALUES ('$username','$password')"; $results=mysql_query($query); And the stored value will be MD5 hashed. If you aren't declaring the password, you're just relying on the server letting you grab the POSTed value without declaring it, you should declare it for compatibility. neenach2002 06-27-2004, 11:23 AM Actually...I haven't made an installer. I'm doing it by hand through the database. Nevermore 06-27-2004, 12:09 PM What are you using to interface with the database? It probably doesn't have MD5 capabilities. You can hash the passwords here: http://bfl.rctek.com/tools/?tool=hasher and then enter them by hand. neenach2002 06-27-2004, 12:31 PM I'm developing my own member system. Hand coded 100%. Nevermore 06-27-2004, 12:36 PM I don't 100% understand this... you're saying you're making a member management system but that you are adding members by hand not automatically? Please explain. neenach2002 06-27-2004, 12:57 PM The members will be added automatically. Upon registration, I want their passwords to be MD5ed. I just figured out part of my problem. The data itself get's MD5ed, but you can't set it in the general database table. It's on a row-by-row basis. Nevermore 06-27-2004, 01:04 PM What code are you using to add the members at the moment? neenach2002 06-27-2004, 01:07 PM As of yet, none....I'm still doing the database. I haven't started user-creation yet. Though I did do some of the registration form, it's not functional yet. Nevermore 06-27-2004, 02:05 PM Well, when you do write the code, to MD5 the value before insertion just run the md5() function on the variable. neenach2002 06-27-2004, 02:09 PM $password=md5($_POST['password']); Right? ShrineDesigns 06-27-2004, 02:11 PM setup your table like this:CREATE TABLE `members` (`username` VARCHAR(255) NOT NULL, `password` VARCHAR(64) NOT NULL, UNIQUE (`username` (128)), INDEX (`password` (32)))and insert rows with a query like this:INSERT INTO `members` VALUES ('$username', MD5('$password'))MySQL has a built in MD5() function Nevermore 06-27-2004, 02:24 PM Cool; I was never sure how to use the MySQL MD5. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |