PDA

View Full Version : md5


RyanB88
03-06-2005, 07:17 PM
how would i get a php script to take the valuse of a text filed and insert it into the db, also how can i make it encrypt a password valuse using md5 then store that in the db?

would this work?

<?php

echo "Username: <input type='text' name='username'>"
// Connect to the database by calling $link which is defined in config.php (which i required in this file)
$link;

some qury i am not sure what using $username

echo "Password: <input type='password' name='password'>"
// Connect to the database by calling $link which is defined in config.php (which i required in this file)
$link;

$passwd = md5('$password')

some qury i am not sure what using $passwd

?>

Now i am probably far off but i am still learning php and mysql queries.

cooleo100d
03-06-2005, 07:25 PM
Hi,

To encrypt a password, all you need to do is:


$password = md5($password);


Then you would just insert $password into the database. Then to compare an inputed password to the one in the database, you would do something like:


if (md5($inputtedpassword) == $password)


Hope this helps,
~David

RyanB88
03-06-2005, 07:31 PM
Hi,

To encrypt a password, all you need to do is:


$password = md5($password);


Then you would just insert $password into the database. Then to compare an inputed password to the one in the database, you would do something like:


if (md5($inputtedpassword) == $password)


Hope this helps,
~David

well that answers part of the question.

Thanks for the quick response.

RyanB88
03-11-2005, 04:18 PM
can anybody tell me how to assign a variable to what a user enters in a text field?

devinemke
03-11-2005, 04:20 PM
can anybody tell me how to assign a variable to what a user enters in a text field?
PHP does that for you via the $_POST and $_GET arrays

RyanB88
03-11-2005, 04:23 PM
PHP does that for you via the $_POST and $_GET arrays

can you please show me an example, i am new to php

devinemke
03-11-2005, 04:29 PM
<?php
if (!isset($_POST['submit']))
{
echo '
<form action="" method="POST">
name: <input type="text" name="name">
<input type="submit" name="submit" value="submit">
</form>
';
}
else
{
echo 'you entered: ' . $_POST['name'];
}
?>

RyanB88
03-11-2005, 04:39 PM
ok thanks. ;)