Submit links

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zeds
Forum Newbie
Posts: 2
Joined: Sun Apr 06, 2008 4:01 am

Submit links

Post by zeds »

I wonderd if there was anyway using a commet system that the user could enter an url say there site or something and it would appear as a hyperlink I've bieng trying to work it out using this...

Code: Select all

<?PHP
 
$filename = "guestbook.txt"; #CHMOD to 666
$text = "";
 
if (isset($_POST["submit"])) {
$name = htmlspecialchars($_POST["name"]);
$message = htmlspecialchars($_POST["message"]);
 
$date = date ("l, F jS, Y");
$time = date ("h:i A");
 
$value = $message."<br>\n<span style=\"font-family: verdana, arial, sans-serif; font-size: 70%; font-weight: bold;\">Posted by $name at $time on $date.</span>\n<break>\n";
 
##Write the file##
 
$fp = fopen ($filename, "a");
if ($fp) {
fwrite ($fp, $value);
fclose ($fp);
}
else {
echo ("Your entry could not be added.");
}
}
 
?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Guestbook</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
 
<body>
<form action="<?PHP echo $_SERVER["PHP_SELF"]; ?>" method="post">
<p>Your Message:<br>
<textarea name="message" rows="7" cols="50"></textarea><br>
Your Name: <input type="text" name="name">
<input type="submit" name="submit" value="submit"></p>
</form>
 
<?PHP
 
$contents = @file($filename) or die("No files in guestbook.");
 
foreach ($contents as $line_num => $line) {
$text .= $line;
}
 
$text = split("<break>", $text);
 
for ($i=0; $i<count($text)-1; $i++) {
echo "<div style=\"border: gray 1px solid; padding: 5px; font-family: arial, sans-serif; background-color: #eeeeee;\">";
echo $text[$i];
echo "</div>";
}
 
?>
</body>
</html>
zeds
Forum Newbie
Posts: 2
Joined: Sun Apr 06, 2008 4:01 am

Re: Submit links

Post by zeds »

Anyone? :?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Submit links

Post by John Cartwright »

We do not allow bumping within 24 hours of your last post. Please read the forum rules in my signature.
Post Reply