oaklinnet Posted September 10, 2010 Report Share Posted September 10, 2010 hello all been trying for some time to make a web page with a new player register on it so they don't have to wait for me to add them. i'm been trying to do it in php keep hanging up on the password part was going to use the one in the Source Code but i seen that it use a .cgi file that was not there to go by i got most of it ok but when it add the password it wont hash in the db any help Quote Link to comment Share on other sites More sharing options...
karu [WDL] Posted September 10, 2010 Report Share Posted September 10, 2010 i got most of it ok but when it add the password it wont hash in the dbpassword is md5 hash Quote Link to comment Share on other sites More sharing options...
Seeker Posted September 10, 2010 Report Share Posted September 10, 2010 // check for valid details $sql = "INSERT INTO `net7_user`.`accounts` (`username`, `password`, `status`, `email`) VALUES ('$username', '".MD5($password)."', '0', 'noemail@net-7.org');"; Quote Link to comment Share on other sites More sharing options...
C Del[IS] Posted September 11, 2010 Report Share Posted September 11, 2010 You're not actually connecting and running the query. Add the following after you declare $sql, your query string: // Connect to the database $conn = mysql_connect(your_mysql_address, mysql_user, mysql_password); // Open the user database mysql_select_db("net7_user", $conn); // You need to check if the username is already taken here $query = "SELECT * FROM accounts WHERE username = '$username';"; $result = $mysql_query($query, $conn) or die("MySQL fail!"); if (mysql_num_rows($result) > 0) die("Username taken!"); // Execute the query the insert the account record mysql_query($sql, $conn)) or // Tell the user it failed die("Something went crazy with the databse!\nSQL Error (" . mysql_errno . "): " . mysql_error()); // Tell the user it succeeded I'm not really a PHP programmer, so I might have made a mistake, but I'm fairly certain that should work for everything you need. Also, I have to ask. How many people are connecting to your server that you need a registration script? lol Quote Link to comment Share on other sites More sharing options...
Slayerman Posted September 11, 2010 Report Share Posted September 11, 2010 You will need to match the passwords too. $query = "SELECT * FROM accounts WHERE username = '$_REQUEST['username'] and password=MD5($_REQUEST['password']"; $result = $mysql_query($query, $conn) or die("MySQL fail!"); A hashed password from the sign in page should match the MD5 hashed password in the database. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.