Problem 1:
Where to put htmlentities on page 4? I tried every possibility but I always see bad text on page 3 and page 5 AFTER using page 4. BEFORE using page 4, page 3 and 5 is OK.
Problem 2:
ÒSELECTEDÓ on page 4 doesnÕt work. It always selects the first possibility. IÕ think this has also something to do with the special characters, because it works in other databases with words without special characters.
page 1: invulformulier.php
<html>
<head>
<title>
Invulformulier
</title>
</head>
<body>
<form name="wijn" method="post" action="toevoegen.php">
<p>
<label>
<select name="domein">
<option value="Château La Fleur Cailleau">Château La Fleur Cailleau</option>
<option value="Château La Grave">Château La Grave</option>
<option value="Domaine du Petit Malromé">Domaine du Petit Malromé</option>
</select>
</label>
</p>
<p>
<input type="text" name="naam" size="50" maxlength="50">
</p>
<p>
<label>
<textarea name="beschrijving" cols="50" rows="20"></textarea>
</label>
</p>
<p>
<input type="submit" value="bevestigen">
<input type="reset" value="wissen">
</p>
</form>
</body>
</html>
page 2: toevoegen.php
<?php
include("inc_connect.php");
$domein = $POST['domein'];
$naam = $POST[ÔnaamÕ];
$beschrijving = $_POST['beschrijving'];
?>
<html>
<head>
<title>Gegevens toevoegen</title>
</head>
<body>
<?php
$sql = "INSERT INTO wijn (domein, naam, beschrijving) values ('$domein', Ô$naamÕ, '$beschrijving')";
mysql_query($sql)or die("Er gebeurde een fout tijdens het versturen van uw gegevens: ".mysql_error());?>
<h1>De volgende gegevens zijn toegevoegd:</h1>
<p><b>Domein: </b> <?php echo htmlentities($POST["domein"]);?></p>
<p><b>Naam: </b> <?php echo htmlentities($POST["naam"]);?></p>
<p><b>Beschrijving: </b></p><p> <?php echo htmlentities($_POST["beschrijving"]);?></p>
</body>
</html>
page 3: overzicht .php
<?php
include("inc_connect.php");
$fout = "FOUT: openen database mislukt";
$query="SELECT * FROM wijn ORDER BY naam";
$result = mysql_query($query) or die (mysql_error());
?>
<html>
<head>
<title>Wijn: overzicht</title>
</head>
<body>
<table>
<tr>
<th>Domein</th>
<th>Naam</th>
<th>Beschrijving</th>
<th>Bewerken</th>
</tr>
<?php
while (list($id, $domein, $naam, $beschrijving) = mysql_fetch_row($result)){
echo("<tr>
<td>" . htmlentities($domein) . "</td>
<td>" . htmlentities($naam) . "</td>
<td>" . htmlentities($beschrijving) . "</td>
<td><a href=\"bewerken.php?id=$id\">Bewerken</a></td>
</tr>
\n");
}
?>
</body>
</html>
page 4: bewerken.php
<?php
include("inc_connect.php");
if (isset($POST["bevestiging"])){
$query="UPDATE wijn SET
domein = '". $POST["domein"] ."',
naam = '". $POST["naam"] ."',
beschrijving = '". $POST["beschrijving"] ."'
WHERE id='" .$_POST["id"] ."'";
$result = mysql_query($query) or die ("FOUT: " . mysql_error());
if ($result){
echo("Gegevens wijn zijn bijgewerkt");
}
}else{
$query="SELECT * FROM wijn WHERE id='" . $_GET["id"] ."'";
$result = mysql_query($query) or die ("FOUT: " . mysql_error());
?>
<html>
<head>
<title>Bewerken </title>
</head>
<body>
<?php
while (list($id, $domein, $naam, $beschrijving) = mysql_fetch_row($result)){
$a = $domein;
$b = $naam;
$c = $beschrijving;
}?>
<form action="<?php echo($SERVER["PHP_SELF"]);?>" method="post">
<input type="hidden" name="bevestiging" value="1">
<input type="hidden" name="id" value="<?php echo($GET["id"]);?>">
<p>
<label>
<select name="domein">
<option value="Château La Fleur Cailleau" <?php if($a=="Ch\âteau La Fleur Cailleau"){echo "SELECTED";}?>>Château La Fleur Cailleau</option>
<option value="Château La Grave" <?php if($a=="Ch\âteau La Grave"){echo "SELECTED";}?>>Château La Grave</option>
<option value="Domaine du Petit Malromé" <?php if($a=="Domaine du Petit Malrom\é"){echo "SELECTED";}?>>Domaine du Petit Malromé</option>
</select>
</label>
</p>
<p>
<input type="text" name="naam" size="50" maxlength="50" value="<?php echo ($b);?>">
</p>
<p>
<label>
<textarea name="beschrijving" cols="50" rows="20"><?php echo ($c);?></textarea>
</label>
</p>
<p>
<input type="Submit" value="Wijziging bevestigen">
<input type="Button" value="Wijziging niet doorvoeren" onclick="javascript:history.back();">
</p>
</form>
<?php
}
?>
</body>
</html>
page 5: wijn.php
<?php
include("../../php/inc_connect.php");
$fout = "FOUT: openen database mislukt";
$query="SELECT * FROM wijn ORDER BY naam";
$result = mysql_query($query) or die (mysql_error());
?>
<html>
<head>
<title>PRO VINO VERO</title>
</head>
<body>
<?php
while (list($id, $domein, $naam, $beschrijving) = mysql_fetch_row($result)){
echo(" <h1>" . htmlentities($domein) . "<br>" . htmlentities($naam) . "</h1>
<p> " . htmlentities($beschrijving) . " </p>");
}
?>
</body>
</html>