Nieuw lid |
|
hallo,
Ik ben nu bezig om mijn gastenboek te maken zonder database, alleen het gaat niet zoals ik het zou willen. Dus ik heb de volgende bestanden gemaakt guestbook.php en messages.txt(HIERIN WORDEN ALLE BERICHTEN OPGESLAGEN)
Ik heb de volgende in het bestand guestbook.php gezet:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Postavite vase omiljene YouTube video klip-ove!</title>
<?php
$file_name = "messages.txt";
$post_sep = "<>";
$info_sep = "&";
class writePosts {
function inputPost($author, $message) {
global $file_name, $post_sep, $info_sep;
$date = time();
$self = $_SERVER['PHP_SELF'];
$author = urlencode($author);
$message = urlencode($message);
$fh = fopen($file_name, "r+");
fread($fh, filesize($file_name));
fwrite($fh, $author.$info_sep.$date.$info_sep.$message.$post_sep);
fclose($fh);
echo "<script>window.location = '$self'; </script>";
}
function getPost() {
if (isset ($_POST['author']) && isset($_POST['message'])) {
$this inputPost($_POST['author'], $_POST['message']);
}
}
}
class readPosts{
function readAll() {
global $file_name, $post_sep, $info_sep;
$fh = fopen($file_name, "r");
$all = fread($fh, filesize($file_name)};
fclose($fh);
$each = explode($post_sep, $all);
$i = 0;
$counteach = count($each);
while($i< $counteach = 1) {
$post_info = explode($info_sep, $each[$i]);
$this outPost($post_info[o], $post_info[1], $post_info[2];
$i++;
}
}
function outPost($author, $date, $message)($date = date("m/d/y", $date);
$author = urldecode($author);
$message = urldecode($message);
echo "<div>";
echo "( $date ) <strong>$author says:</strong><br />";
echo "$message </div>";
}
}
$write = new writePosts;
$read = new readPosts;
$write getPost();
?>
</head>
<body>
<h1><div align="center">Postavite vase omiljene YouTube video klip-ove!</div></h1>
</table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<td>
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td width="117">Name</td>
<td width="14">:</td>
<td width="357"><input name="author" type="text" id="author" size="40" /></td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">:</td>
<td><textarea name="message" cols="40" rows="3" id="message"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td>
</tr>
</table>
</td>
</form>
<?php $read readAll(); ?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Postavite vase omiljene YouTube video klip-ove!</title> <?php $file_name = "messages.txt"; $post_sep = "<>"; $info_sep = "&"; class writePosts { function inputPost($author, $message) { global $file_name, $post_sep, $info_sep; $self = $_SERVER['PHP_SELF']; $fh = fopen($file_name, "r+"); fwrite($fh, $author.$info_sep.$date.$info_sep.$message.$post_sep); echo "<script>window.location = '$self'; </script>"; } function getPost() { if (isset ($_POST['author']) && isset($_POST['message'])) { $this inputPost($_POST['author'], $_POST['message']); } } } class readPosts{ function readAll() { global $file_name, $post_sep, $info_sep; $fh = fopen($file_name, "r"); $i = 0; $counteach = count($each); while($i< $counteach = 1) { $post_info = explode($info_sep, $each[$i]); $this outPost($post_info[o], $post_info[1], $post_info[2]; $i++; } } function outPost ($author, $date, $message)($date = date("m/d/y", $date); echo "( $date ) <strong>$author says:</strong><br />"; } } $write = new writePosts; $read = new readPosts; $write getPost(); ?> </head> <body> <h1><div align="center">Postavite vase omiljene YouTube video klip-ove!</div></h1> </table> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action=" <?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <td> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td width="117">Name</td> <td width="14">:</td> <td width="357"><input name="author" type="text" id="author" size="40" /></td> </tr> <tr> <td valign="top">Comment</td> <td valign="top">:</td> <td><textarea name="message" cols="40" rows="3" id="message"></textarea></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> </tr> </table> </td> </form> <?php $read readAll(); ?> </body> </html>
Als ik een bericht + mij naam intyp, vervolgens doe ik op submit, dan moet mij bericht met mijn naam en datum in messages.txt worden opgeslagen.
Gelijk daarna moet het op mijn website leezbaar zijn, maar er wordt nieks opgeslagen en niet getoond.
Als ik op submit druk krijg ik de volgende melding: Kan file//gastenboek/%3C?PHP echo $ SERVER['PHP_SELF'];?> NIET VINDEN
vinTage schreef: vinTage was here, with code tags!
|