simple MD5 help
Posted: Tue Dec 09, 2008 5:25 am
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Basically, Im using the following code for a simple project that I've been messing around with. It does what I need it to do in terms of allowing the user to register etc. Now I want to look at validatation and security.
What I need to do is use the MD5 function to encrypt the database passwords. It's probably quite simple but Ive tried a couple of methods and havent managed to get it working yet. Any help is greatly appreciated. Thanks
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Basically, Im using the following code for a simple project that I've been messing around with. It does what I need it to do in terms of allowing the user to register etc. Now I want to look at validatation and security.
Code: Select all
<div id="content">
<?php
// Check if he wants to register:
if (!empty($_POST[username]))
{
// Check if passwords match.
if ($_POST[password] != $_POST[password2])
exit("Error - Passwords don't match. Please go back and try again.");
require_once("connect.php");
//$password = md5($password);
// Register him.
$query = mysql_query("INSERT INTO members
(username, firstname, lastname, password)
VALUES ('$_POST[username]','$_POST[firstname]','$_POST[lastname]','$_POST[password]')")
or die ("Error - Couldn't register user.");
echo "Congratulations $_POST[username]! You've successfully registered!<br /><br />
Please continue to the <a href='login.php'><b>login</b></a> page in order to access all of the wonderful members features.";
exit();
}
?>
<form action="register.php" method="post">
<table width="75%" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td width="100%"><label>Desired Username: <input type="text" name="username" size="25" value=""></label></td>
</tr>
<tr>
<td width="100%"><label>First Name: <input type="text" name="firstname" size="25" value=""></label></td>
</tr>
<tr>
<td width="100%"><label>Last Name: <input type="text" name="lastname" size="25" value=""></label></td>
</tr>
<tr>
<td width="100%"><label>Password: <input type="password" name= "password" size="25" value=""></label></td>
</tr>
<tr>
<td width="100%"><label>Verify Password: <input type="password" name="password2" size="25" value=""></label></td>
</tr>
<tr>
<td width="100%"><input type="submit" value="Register"></td>
</tr>
</table>
</form>
</div>~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: