Guestbooks
Moderator: General Moderators
-
Chocolate_Raindrop
- Forum Newbie
- Posts: 11
- Joined: Thu May 20, 2004 6:07 pm
- Location: Alabama
- Contact:
Guestbooks
I'm new at this so I really don't know what I'm doing. I'm trying to get the information from a form to post to the bottom of the page. Can anyone please help me. 
Recommend you go somewhere like http://www.w3schools.com/php/default.asp and do some tutorials. There's plenty of them.
Chocolate_Raindrop if you want you can rent a programer like myself to do the project for you. Go here for more information viewtopic.php?t=21799 . I know its open source and for free and every thing but a man must eat. Enjoy
you make it sound like us /programmers/ are machines, lol. You can rent em?doggy wrote:Chocolate_Raindrop if you want you can rent a programer like myself to do the project for you. Go here for more information viewtopic.php?t=21799 . I know its open source and for free and every thing but a man must eat. Enjoy
You can /contract/ me to complete the projet for you with a cash transfer for the services
-
Chocolate_Raindrop
- Forum Newbie
- Posts: 11
- Joined: Thu May 20, 2004 6:07 pm
- Location: Alabama
- Contact:
Please help fix this problem for me.
Can someone look at my website and tell me what I'm doing wrong. I got this script from Hitech-Scripts.com and it works. Well at least that's what I thought. When I tested it out all the information posted but when I wanted to add another post to the top or bottom of the page it doesn't show the post that was previously entered. My web address is http://www.icdat.cc/cdrop/index2.html
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
Chocolate_Raindrop
- Forum Newbie
- Posts: 11
- Joined: Thu May 20, 2004 6:07 pm
- Location: Alabama
- Contact:
Thank you for helping me
This is the php code for my guestbook.
feyd|use
Code: Select all
<?php
//***********************************************************
//*
//* guestbook.php - a Guestbook script
//* (c) Hitech Scripts 2003
//* For more information, visit http://www.hitech-scripts.com
//*
//***********************************************************
$filename = "guestbook.html";
$title = "Welcome To My Chocolate Factory Guestbook";
$store_ip = 0;
error_reporting(0);
if (($action == "sign") || ($action == "post")) {
$header = get_header();
echo $header;
}
if ($action == "sign")
{
$form_text = get_form();
echo $form_text;
}
if ($action == "post")
{
$date = date ("l dS of F Y h:i:s A");
$name = htmlentities($name);
if ($site_url != "") {
$site_url = htmlentities($site_url);
$url_checker = explode("http://", $site_url);
if (!IsSet($url_checker[1])) {
$site_url = "http://$site_url";
} else {
$site_url = "$site_url";
}
}
else {
$site_url = "none";
}
if ($site_url <> "none") {
$name = '<a target=_blank href="' . $site_url . '">' . $name . "</a>";
}
if ($email != "") {
$email = htmlentities($email);
$email_checker = explode("@", $email);
if (!IsSet($email_checker[1])) {
$email = "none";
} else {
//email checked
}
}
$ip_address = getIP();
$location = htmlentities($location);
$comments = htmlentities($comments);
$comments = parse_smiles($comments, array(':)' => "biggrin-c.gif", ':?' => "confused-c.gif", 'B)' => "cool-c.gif", ':(' => "cry.gif", 'F:' => "frown-c.gif", 'D)' => "shiny.gif", ')D' => "smile-c.gif", ';)' => "wink-c.gif"));
if (is_writable($filename)) {
$file = @fopen($filename, "r");
$result = fread($file, filesize($filename));
fclose($file);
}
else {
$footer = get_footer();
$file = @fopen($filename, "w");
$guest_text = $header . '<!--Guestbook_start--> <!--Guestbook_end-->' . $footer;
fwrite($file, $guest_text);
fclose($file);
chmod ($filename, 0775);
$result = $guest_text;
}
$checker = explode("<!--Guestbook_start-->", $result);
$msg = get_message($date, $name, $email, $ip_address, $location, $comments);
$guest_text = $checker[0] . '<!--Guestbook_start-->' . $msg . $checker[1];
$file = @fopen($filename, "w");
fwrite($file, $guest_text);
fclose($file);
chmod ($filename, 0775);
echo $msg;
}
if (($action != "sign") && ($action != "post")) {
if (is_writable($filename)) {
$file = @fopen($filename, "r");
$result = fread($file, filesize($filename));
fclose($file);
echo $result;
}
exit;
}
$footer = get_footer();
echo $footer;
exit;
//-------------------------------------------------------------------------------------------------
function get_message($date, $name, $email, $ip_address, $location, $comments) {
$msg = '<!-- IP address - ' . $ip_address . ' -->
<br>
<br>
<table width="100%">
<tr>
<td width="100"><b>Name:</b></td>
<td>' . $name . '</td>
</tr>
<tr>
<td><b>Email:</b></td>
<td>' . $email . '</td>
</tr>
<tr>
<td><b>Location:</b></td>
<td>' . $location . '</td>
</tr>
<tr>
<td><b>Date:</b></td>
<td>' . $date . '</td>
</tr>
<tr>
<td colspan="2"><b>Comments:</b></td>
</tr>
<tr>
<td colspan="2" align="left">' . $comments . '</td>
</tr>
<tr>
<td colspan="2"><hr></td>
</tr>
</table>
</div>';
return $msg;
}
//-------------------------------------------------------------------------------------------------
function get_form() {
$form_text = '<form action="guestbook.php" METHOD="POST">
<input name="action" type="hidden" value="post">
<table border="0" align="center">
<tr><td><font size="4">Name:</td><td><input name="name" size="48" type="text" value=""><br></td></tr>
<tr><td><font size="4">Email:</td><td><input name="email" size="48" type="text" value=""><br></td></tr>
<tr><td><font size="4">Site url:</td><td><input name="site_url" size="48" type="text" value=""><br>
<tr><td><font size="4">Location:</td><td><input name="location" size="48" type="text" value=""><br>
<tr><td valign="top"><font size="4">Comments:</td><td><textarea name="comments" rows="8" cols="36"></textarea>
<br><center>
<input value="Sign" type="submit"> <input type="reset"></td>
</tr>
</table>
</form>
';
return $form_text;
}
//-------------------------------------------------------------------------------------------------
function get_header() {
global $title, $filename;
$header = '<html>
<head>
<title>' . $title . '</title>
</head>
<body bgcolor="#663300" text="#33000" link="#330000" alink="#330000" vlink="#330000">
<center><h1>' . $title . '</h1>
<table width="350">
<tr>
<td align=center><a href="guestbook.php?action=sign">Sign to guestbook</a></td>
<td align=center><a href="' . $filename . '">View guestbook</a></td>
</tr>
</table>
';
return $header;
}
//-------------------------------------------------------------------------------------------------
function get_footer() {
$footer = '</center> <center>Powered by <a href="http://www.hitech-scripts.com">Hitech-scripts.com</a></center></body></html>';
return $footer;
}
//-------------------------------------------------------------------------------------------------
function parse_smiles($msg, $parse_string='nil')
{
if (is_array($parse_string))
{
while (list($name, $parse_value) = each ($parse_string))
{
$parse_value1 = '<img src="smiles/'. $parse_value . '" width="17" height="17" border="0">';
$msg = str_replace($name, $parse_value1, $msg);
}
}
return $msg;
}
//-------------------------------------------------------------------------------------------------
function getIP()
{
global $store_ip;
$ip;
if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
else $ip = "UNKNOWN";
if ($store_ip == 0) { $ip = "unknown"; }
return $ip;
}
//-------------------------------------------------------------------------------------------------
?>Code: Select all
tags..[/color]-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
Chocolate_Raindrop
- Forum Newbie
- Posts: 11
- Joined: Thu May 20, 2004 6:07 pm
- Location: Alabama
- Contact:
-
Chocolate_Raindrop
- Forum Newbie
- Posts: 11
- Joined: Thu May 20, 2004 6:07 pm
- Location: Alabama
- Contact: