-2

I have a form and have some fields in it. Check box is also fields for hobbies and when i submit that form then values are inserted in database and it redirect to another form and show the values from database in table format.But I have a problem when showing the result in table manner is it is not showing the values of all selected check boxes it just show the last selected check box's value. And one more thing can i show password in * form or hash form not just simple text form when showing in table format

<head>
<title>Sunil1</title>
</head>
<?php
mysql_connect("localhost","root","")or die("Unable to create to connection");
mysql_select_db("sunil") or die(mysql_error());
$Name1=$_POST["t1"];
$Name2=$_POST["t2"];
$Sex=$_POST["sex"];
$Country=$_POST["Country"];
$Hobby=$_POST["check"];
$Email=$_POST["t3"];
$Pass=$_POST["p1"];
$Repass=$_POST["p2"];
$sql="INSERT INTO registration (First_Name,Last_Name,Sex,Country,Hobbies,Email,Password,Repassword) VALUES('$Name1','$Name2','$Sex','$Country','$Hobby','$Email','$Pass','$Repass')";
mysql_query($sql);
print"Data Submitted Successfully";
$result = mysql_query("SELECT * FROM registration");
print "<table border=1>";
while($row = mysql_fetch_array($result))
{
        print "<tr>";
        print "<td>".$row['First_Name']."</td>";
        print "<td>".$row['Last_Name']."</td>";
        print "<td>".$row['Sex']."</td>";
        print "<td>".$row['Country']."</td>";
        print "<td>".$row['Hobbies']."</td>";
        print "<td>".$row['Email']."</td>";
        print "<td>".$row['Password']."</td>";
        print "<td>".$row['Repassword']."</td>";
        print "</tr>";
}
print "</table>";
?>
  • 1
    @Sunil-Bhai Please paste your code as well. – Roopendra Nov 25 '13 at 12:38
  • *"And one more thing can i show password in * form or hash form not just simple text form when showing in table format"* - Passwords saved as simple text is not a good idea. You might find that out "the hard way" later on. Good luck with that. – Funk Forty Niner Nov 25 '13 at 12:42
  • I had paste it tell me where to use md5() here – Sunil Pachlanga Nov 25 '13 at 12:50
  • What about my first question of inserting check boxes values i haven't get any result yet – Sunil Pachlanga Nov 25 '13 at 12:58
  • Since you already accepted the answer below, you'll need to post a new question. And do take my suggestions seriously, and also use `MySQLi_` with prepared statements or use PDO instead of `MySQL_`. Your site stands at eventually getting hacked; it's just a question of time. [**Read this**](http://stackoverflow.com/q/60174/1415724) – Funk Forty Niner Nov 25 '13 at 13:11

1 Answers1

0

for password please write like this

print "<td>".md5($row['Password'])."</td>"; or print "<td>".md5('$row['Password']')."</td>";

this will display your password in hash.

Ankur Dhanuka
  • 1,217
  • 2
  • 11
  • 22