View guestbook : Login Form « Login Authentication « PHP






View guestbook

 
<html>
<head>
<title>View guestbook</title>
</head>
<body>
<h3>Latest 3 guestbook entries...</h3>

<?php

$rs = @mysql_connect( "localhost", "userName", "password" )or die( "Could not connect to MySQL" );

$rs = @mysql_select_db( "my_database" ) or die( "Could not select database" );

$sql = "select * from guestbook order by time desc limit 3";

$rs = @mysql_query( $sql ) or die( "Could not execute SQL query" );

while ( $row = mysql_fetch_array( $rs ) ) 
{
?>

<table>
<tr>
<td><b>Name:</b> <?php echo $row["name"]; ?></td>

<td><b>Email:</b> <a href="mailto:<?php echo $row["email"]; ?>">
           <?php echo $row["email"]; ?></a> </td><tr>
<tr><td colspan="2">
  <?php

  $datetime = $row["time"];
  $year = substr( $datetime, 0, 4 );
  $mon  = substr( $datetime, 4, 2 );
  $day  = substr( $datetime, 6, 2 );
  $hour = substr( $datetime, 8, 2 );
  $min  = substr( $datetime, 10, 2 );
  $sec  = substr( $datetime, 12, 2 );
  $orgdate = date("l F dS, Y h:i A",mktime( $hour, $min, $sec, $mon, $day, $year ) );
  ?>
Date: <?php echo $orgdate; ?></td></tr>

<tr><td colspan="2"><b>Comments:</b> <?php echo $row["comments"]; ?></td></tr>
</table>
<br>

<?php } ?>

</body>
</html>
  
  








Related examples in the same category

1.Login form with Error Messages and Preserving User Input
2.Hard code login Form
3.A More Sophisticated Login Page
4.A Simple Login Page
5.A Simple User Authentication Script
6.Log-In Page
7.Verifying a login cookie