note 83092 added to function.convert-uudecode
| From: | VipindasK dot S at osu1 dot php dot net | Date: | Fri, 09 May 2008 15:58:18 +0000 |
| Subject: | note 83092 added to function.convert-uudecode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139218@lists.php.net to get a copy of this message | ||
Code snippet for retrieving Encoded passwords stored in mysql database .
Consider a file named "test.php" consisting of an input form as given below:
<html>
<body>
<form action="test.php" method="post">
<input type="text" name="fname" id="fname" />
<input type="password" name="password" id="password" />
<input type="submit" name="submit" value="submit" />
</form>
<?
/*
below php code takes input field values , encode the password and then store the values in a
database .
Create a table named test with fields id,name,password where id is auto incremented..
*/
if(isset($_post['submit']))
{
$fname=$_POST['fname'];
$pass=$_POST['password'];
$encoded_pass=convert_uuencode($pass);
$con=mysql_connect("your hostname","your username","your password");
//connecting to the database
$db=mysql_select_db("your_database_name",$con);
$sql="INSERT INTO test (id,name,password) VALUES('','$fname',
'$encoded_pass' )";
$result=mysql_query($sql)or die("unable to insert");
/****encoding and storing ends here******/
/* Code snippet for retrieving the last inserted entry from the database and decoding starts here */
$id2=mysql_insert_id(); // id of the last entry
$sql2="select password from test where id='$id2' ";
$result2=mysql_query($sql2);
$row=mysql_fetch_array($result2);
$decoded_pass=convert_uudecode($row[0]); //decoding takes place here
echo "decoded password: ".$decoded_pass;
}
?>
</body>
</html>
----
Server IP: 59.162.86.33
Probable Submitter: 59.93.9.84
----
Manual Page -- http://www.php.net/manual/en/function.convert-uudecode.php
Edit -- https://master.php.net/note/edit/83092
Del: integrated -- https://master.php.net/note/delete/83092/integrated
Del: useless -- https://master.php.net/note/delete/83092/useless
Del: bad code -- https://master.php.net/note/delete/83092/bad+code
Del: spam -- https://master.php.net/note/delete/83092/spam
Del: non-english -- https://master.php.net/note/delete/83092/non-english
Del: in docs -- https://master.php.net/note/delete/83092/in+docs
Del: other reasons-- https://master.php.net/note/delete/83092
Reject -- https://master.php.net/note/reject/83092
Search -- https://master.php.net/manage/user-notes.php