dreamweaverfan
Gebruiker
- Lid geworden
- 16 jun 2010
- Berichten
- 226
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>
<script src="../script/shout.php" type="text/php" language="php"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Reacties van anderen</title>
</head>
<body>
<input type="button" value="plaats reactie">
</body>
</html>
Zoals u ziet is dit een aanroep pagina voor een shoutbox:
PHP:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?PHP
error_reporting(E_ALL);
$bestand = fopen('shoutboxtext.txt','a+');
$regels = file('shoutboxtext.txt');
if ( isset ( $_POST['submit'] ) ) {
if ( !empty( $_POST['name'] ) && !empty( $_POST['msg'] ) ){
$shout = '<b>' . htmlspecialchars($_POST['name']) . '</b>: ' . htmlspecialchars($_POST['msg']);
// echo $shout;
fwrite($bestand,"\n$shout");
fclose($bestand);
header('Location: shoutbox.php');
}
else {
echo 'You didn\'t fill in you\'re name and/or message';
}
}
fclose($bestand);
if ( isset ( $_GET['show'] ) ) {
if ( $_GET['show'] == 'all'){ $hoeveel = count($regels); }
else { $hoeveel = $_GET['show']; }
}
else {
$hoeveel = 10;
}
for($i=count($regels);count($regels)-$i<$hoeveel;$i--){
echo $regels[$i-1] . '<br />';
}
?>
<a href="shoutbox.php?show=all">Show all</a><br />
<a href="shoutbox.php?show=5">Show 5</a><br />
<form action="shoutbox.php" method="post">
Naam: <input type="text" name="name" /> <br />
Bericht: <input type="text" name="msg" /> <br />
<input type="submit" name="submit" value="Shout!">
</form>
</body>
</html>
Zo kunnen bezoekers reactie plaatsen en is dat gelijk zichtbaar op de pagina
wat nu:
Die knop plaats reacctie werkt niet.
Weet iemand hoe ik de code kan aanpassen?
Het liefst had ik een php gastenboek maar die zijn erg ingewikkeld om aan te passen
Laatst bewerkt door een moderator: