Reply
[guestbook] date and posts/page problems
Old 11-07-2007, 08:43 AM [guestbook] date and posts/page problems
Skilled Talker

Posts: 77
Location: Brussels, Belgium
Does someone know how to make this guestbook right?

He always posts the same date/hour/... for each message !
He doesn't post the time when the message actually is sent.

Also, can someone say how to make the script right, so there are only 10 posts per page.

And it generates automatically a link to the next page, where the next 10 messages are posted?

Some parts of the code are in Dutch so here are some translations:
naam = name
bericht = message
rij = row
gastenboek = guestbook
toegevoegd = added
verbinding = connection


This is the form:

PHP Code:
<form action="gbscript.php" method="post" >
<br>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
From:  <input name="naam" maxlength="50"> 
<input name="datum" value="<?php echo date("d-m-Y H:i:s"time()); ?>" type="hidden">
</td>
</tr>
<tr>
<td>
E-mail:  <input name="email" maxlength="50">
</td>
</tr><tr>
<td>
Website:  <input name="website" maxlength="50">
</td>
</tr>
<tr>
<td>
<textarea name="bericht" rows="3" cols="10" maxlength="600">Typ hier uw bericht!</textarea><br>
<input type="submit" name="submit" value="Bericht plaatsen!">
</td>
</tr>
</table>
</form>
gbscript.php:

PHP Code:
<?php 
if(isset($_REQUEST['submit'])) {
if(
strlen($_REQUEST['naam']) == 0
  { 
           echo 
"You forgot to fill in the name of the sender!<br>";
           echo 
"<a href=\"gastenboek.php\">Click here to return</a><br><p>";
  } 
if(!
eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$_REQUEST['email'])) 
  { 
           echo 
"Incorrect e-mail adress of the sender!<br>";
           echo 
"<a href=\"gastenboek.php\">Click here to return</a><br><p>";
  }
$datum $_REQUEST['datum'];
$bericht $_REQUEST['bericht'];
$email $_REQUEST['email'];
$website $_REQUEST['website'];
$naam $_REQUEST['naam'];
$bericht str_replace("\n""<br>"$bericht);
$sql "INSERT INTO `gastenboek` ";
$sql .= "(naam, email, website, bericht, datum) ";
$sql .= "VALUES ";
$sql .= "('$naam', '$email', '$website', '$bericht', '$datum') ";
$sql .= "; ";
require_once(
'mysql_connect.inc.php');
$verbinding = @mysql_connect(MYSQL_SERVERMYSQL_GEBRUIKERSNAAMMYSQL_WACHTWOORD) or die(mysql_error());
mysql_select_db("bulevardibase") or die(mysql_error()); 
$toegevoegd mysql_query($sql) or die(mysql_error());
mysql_close($verbinding);
 
// to post the results of the guestbook: 

if($toegevoegd) {
require_once(
'mysql_connect.inc.php');
$verbinding = @mysql_connect(MYSQL_SERVERMYSQL_GEBRUIKERSNAAMMYSQL_WACHTWOORD) or die(mysql_error());
mysql_select_db("bulevardibase") or die(mysql_error()); 
$sql "SELECT * FROM gastenboek ORDER BY id DESC"
$tonen mysql_query($sql) or die (mysql_error());
 
while (
$rij mysql_fetch_assoc($tonen)) { 
$datum $rij["datum"];
$naam $rij["naam"];
$email $rij["email"];
$website $rij["website"];
$bericht $rij["bericht"];
echo 
$datum ;
echo 
"<br>";
echo 
$naam ;
echo 
"<br>";
echo 
$website ;
echo 
"<br>";
echo 
$bericht ;
echo 
"<br><hr><br>";
 
   }
mysql_free_result($tonen);
mysql_close($verbinding);
 }
}
else {
  echo 
"Please, fill in the form above!<p><br>";
}
?>
Bulevardi is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 11-07-2007, 01:49 PM Re: [guestbook] date and posts/page problems
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Well,
there isn't any problem I can see with your date handling (I assume that all the other details display fine).
I'm afraid that I don't know any more than that, sorry!

I know certain other people in this community would want me to say also:
1) It's best to self-close input tags to make them validate <input ../> and use <br /> not <br>, <hr /> not <hr> Your choice though.
2) Use post rather than request if you know you're not going to need get... otherwise hackers could utilise get in some way.
__________________
Foundation Flash tutorials : www.foundation-flash.com

New Dreamed Up Web Design: www.dreamedupdesign.com
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Reply     « Reply to [guestbook] date and posts/page problems
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12626 seconds with 12 queries