Rohan72
10-31-2007, 06:46 AM
I found a little script to easily insert items into a MySQL dbase. I modified it a bit with the very little knowledge I have on php to accomodate my needs.
Amazingly it worked fine.
Now i would like to check the list on a website (without having to go into phpmyadmin). I also found a script that would do fine with some adjusting.
And here lies problem.
In the 1st script i changed the password to an encrypted on.
I would like to reverse it in the 2nd.
Here are both scripts so u can see what i'm talking about
Script 1 : putting data in dbase
<?php
$host="localhost"; // Host name
$username="*****"; // Mysql username
$password="*****"; // Mysql password
$db_name="*****"; // Database name
$tbl_name="leden"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$lid=$_POST['lid'];
$pasw=$_POST['pasw'];
$pasw_md5=md5($pasw);
// Insert data into mysql
$sql="INSERT INTO $tbl_name(lid, pasw_md5)VALUES('$lid', '$pasw_md5')";
$result=mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='invoeg.php'>Back to main page</a>";
}
else {
echo "ERROR";
}
// close connection
mysql_close();
?>
Script 2 : retrieving data and outputting it in a table
<?php
$host="localhost"; // Host name
$username="*****"; // Mysql username
$password="*****"; // Mysql password
$db_name="*****"; // Database name
$tbl_name="leden"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Retrieve data from database
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>
<table width="500" border="1" cellspacing="0" cellpadding="3">
<tr>
<td width="20%"><? echo $rows['id']; ?></td>
<td width="50%"><? echo $rows['lid']; ?></td>
<td width="30%"><? echo $rows['pasw']; ?></td>
</tr>
</table>
<?
// close while loop
}
// close connection
mysql_close();
?>
I know i have to put somewhere a line to change the encrypted password back to normal.
Can anyone help me on this?
Amazingly it worked fine.
Now i would like to check the list on a website (without having to go into phpmyadmin). I also found a script that would do fine with some adjusting.
And here lies problem.
In the 1st script i changed the password to an encrypted on.
I would like to reverse it in the 2nd.
Here are both scripts so u can see what i'm talking about
Script 1 : putting data in dbase
<?php
$host="localhost"; // Host name
$username="*****"; // Mysql username
$password="*****"; // Mysql password
$db_name="*****"; // Database name
$tbl_name="leden"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$lid=$_POST['lid'];
$pasw=$_POST['pasw'];
$pasw_md5=md5($pasw);
// Insert data into mysql
$sql="INSERT INTO $tbl_name(lid, pasw_md5)VALUES('$lid', '$pasw_md5')";
$result=mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='invoeg.php'>Back to main page</a>";
}
else {
echo "ERROR";
}
// close connection
mysql_close();
?>
Script 2 : retrieving data and outputting it in a table
<?php
$host="localhost"; // Host name
$username="*****"; // Mysql username
$password="*****"; // Mysql password
$db_name="*****"; // Database name
$tbl_name="leden"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Retrieve data from database
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>
<table width="500" border="1" cellspacing="0" cellpadding="3">
<tr>
<td width="20%"><? echo $rows['id']; ?></td>
<td width="50%"><? echo $rows['lid']; ?></td>
<td width="30%"><? echo $rows['pasw']; ?></td>
</tr>
</table>
<?
// close while loop
}
// close connection
mysql_close();
?>
I know i have to put somewhere a line to change the encrypted password back to normal.
Can anyone help me on this?