Displaying Users on a User Registration Website
Introduction.
Now we need to address issues of making things about registered users
available to others. You could choose to make this more secure or
more open depending on the situation. Since we will require more
security when users want to modify or delete their information we will
leave this situation more open. In addition, we will not display all
of the information that is available on each user. Probably the messiest aspect of all of this is getting things to display in a table and coordinating the concomitant jumping between HTML and PHP. We are also going to be needing to pull the information out of the database table. The file should be called display_user_registration.php. |
<?php // assign the values for database access $host = "localhost"; $user = "your_user_name"; $password = "your_password"; $db_name = "database_name"; $table_name = "user_registration"; // connecting to the database on battcave.com $link = mysql_connect($host, $user, $password); // constructing the query string $query_string = "SELECT * FROM $table_name"; $result_set = mysql_db_query($db_name, $query_string, $link); // display the result set in a table // initializing the table and the column headers print("<table border=2 width=900 align=center>"); print("<tr align=center valign=top>"); print("<td align=center valign=top><font size=4><b>User ID</b></font></td>"); print("<td align=center valign=top><font size=4><b>Name</b></font></td>"); print("<td align=center valign=top><font size=4><b>EMail Address</b></font></td>"); print("<td align=center valign=top><font size=4><b>Interests</b></font></td>"); print("<td align=center valign=top><font size=4><b>Credit Card</b></font></td>"); print("<td align=center valign=top><font size=4><b>Education</b></font></td>"); print("<td align=center valign=top><font size=4><b>Registration Date</b></font></td>"); print("</tr>"); // looping through the resultset appending a new row for each record while ($row = mysql_fetch_array($result_set)) {
} |
The form should look like the following. |
You should notice how we have displayed all of the
characteristics of each user, for example we have omitted their password. Notice how I have included a link back to the homepage. Another, possibly more intelligent way to do this would be to put links to the four basic types of functionalities we want to provide
on every page. |