jeg har været igang med at lave en lille tag wall efter en bog jeg har købt har rette alle de fejl som denaf gav når man kørte den. men når jeg har udfyldt formen gemmer det ikke i min dat fil
sådan ser filerne ud
------------------------------------------------------------------------------------------------
book.php
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#ffffff">
<?php
// this is book.php - it accepts form data and writes to a file
// guestbook class included
include("guestbook_inc.php");
// spawn a guestbook
$mybook = new Guestbook();
// set an object property
// make sure you have permissionto write this file
$mybook->usefile('Guestbook.dat');
// use a method of the new object to write data
if($name && $email && $comments)
{
$mybook->add_entry($name,$email,$comments);
}
// onject also includes a method to display previous entries
$mybook->display();
?>
</body>
</html>
----------------------------------------------------------------------------------------------
og guestbook_inc.php
<?php
class guestbook{
// default settings
function Guestbook()
{
$this->title = "min gæstebog";
$this->fontface = "Verdana";
$this->fonsize = "2";
$this->foncolor = "ffoooo";
$this->filename = "default.txt";
}
//set the title
function set_title($title)
{
$this->title = $title;
}
//set font
function set_fontsize($fontsize)
{
$this->fontsize = $fontsize;
}
//set fontface
function set_fontface($fontface)
{
$this->fontface = $fontface;
}
//set fontcolor
function set_fontcolor($fontcolor)
{
$this->fontcolor = $fontcolor;
}
//set name of date file
function usefile($file)
{
$this->filename = $file;
}
//function to actually wrtie form data to file
//elements of each entry are separated by a |
function add_entry($name,$email,$comments)
{
$entry = $name."|".$email."|".$comments."\\n";
$this->fpointer = fopen($this->fielname,"a+");
fputs($this->fpointer,$entry);
fclose($this->fpointer);
}
// spilt entries agenst |
//and call display_entries() function
function split_entries($file)
{
$entries = file($file,"r");
for($counter = 0; $counter < sizeof($entries); $counter++)
{
$entry = explode ("|", $entries[$counter]);
$this->display_entries($entry);
}
}
// display an entry in the guestbook
function display_entries($entry)
{
for($counter = 0;$counter < sizeof($entry);$counter++)
{
print " <center><font face=\\"$this->fontface\\" size=$this->fontsize
color=$this->fontcolor>$entry[$counter]</font></center>";
}
print "<hr width=50%>";
}
// display the title
function display_title()
{
print " <center><font face=\\"$this->fontface\\" size=$this->fontsize
color=$this->fontcolor>$this->title</font></center><hr width=75%>";
}
//display page
function display()
{
$this->display_title();
$this->split_entries($this->filename);
}
}
?>
---------------------------------------------------------------------------------------------------
og guestbook.php
<html><head><title>skriv i min gæstebog</title>
</head>
<body bgcolor="#cacaff">
<form action="book.php" method="post">
<center>
<table width="100%" cellpadding="10" cellspacing="5" >
<tr>
<td width="50%" align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Navn</font></b></td>
<td align="left">
<input type="text" name="name" size="30" maxlength="25">
</td>
</tr>
<tr align="center">
<td width="50%" align="fight"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Email adresse</font></b></td>
<td align="left">
<input type="text" name email" size"30">
</td>
</tr>
<td align="right" width="50%"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Kommentar</font></b></td>
<td align="left">
<textarea name="comments" cols="40" rows="5" wrap="virtual">
det kan ses på
http://www.lommeuld.dk/gb/guestbook.php[Redigeret d. 08/12-02 17:46:33 af martin lund]