Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Guestbook entries

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Guestbook entries

Postby jinx » Wed Jan 22, 2003 2:52 am

See code below.. The php-script writes to a file called guestbook.txt, but the NEW entries comes to the END of the file! I want the new entries to come first. Anyone know how?

--------------
<?php
/* Schtølle Productions 20©02
*/

while(list($key, $val) = each($HTTP_POST_VARS)) {
$val = str_replace("<", "&lt;", $val);
$HTTP_POST_VARS[$key] = str_replace(">", "&gt;", $val);
}
$date = date("m. d. Y H:i:s");
if(empty($name)){ echo "Please enter your name"; exit(); }

$logit = "<font style=\"font-family: verdana; font-size: 8pt;\"><p><b>Nick:</b> ".$HTTP_POST_VARS["name"]."<br>".
"<b>Mail:</b> <a href=\"mailto:".$HTTP_POST_VARS["mail"]."\">".$HTTP_POST_VARS["mail"]."</a><br>".
"<b>Website:</b> <a href=\"http://".$HTTP_POST_VARS["url"]."\">".$HTTP_POST_VARS["url"]."</a><br> <b>Date:</b> $date <br>".
"<b>Location:</b> ".$HTTP_POST_VARS["location"]." <br>";
"<b>Comment:</b><br> ".$HTTP_POST_VARS["comment"]." <br><hr> \n";

$fp = fopen ("guestbook.txt", "a+") or die("Error, something is wrong. Use the contact us-form to report. Thank you");
$logit = stripslashes($logit);
fwrite ($fp, $logit);
fclose ($fp);
header("Location: posted.php");
?>
jinx
New php-forum User
New php-forum User
 
Posts: 12
Joined: Wed Jan 22, 2003 2:47 am
Location: Norway

Postby Joan Garnet » Wed Jan 22, 2003 5:48 am

Use this one:
$fp = fopen ("guestbook.txt", "r+");
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

target="_blank"

Postby jinx » Thu Jan 23, 2003 7:50 am

Thanks a lot!

and..
how do I get the html tag <target="_blank"> to work on the 'website'-field in the same php-file? I want the links to open in a new window..

Erik
http://www.slapthemadcap.com
jinx
New php-forum User
New php-forum User
 
Posts: 12
Joined: Wed Jan 22, 2003 2:47 am
Location: Norway

Postby Joan Garnet » Fri Jan 24, 2003 1:43 am

This way:
Code: Select all
echo "<a href='http://".$HTTP_POST_VARS["url"]."' target='_blank'>".$HTTP_POST_VARS["url"]."</a>";
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron