<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<?php include('bovenmenu.php'); ?>
<?php include('connect.php'); ?>
//ini_set('display_errors', 1);
//error_reporting(E_ALL);
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>verwerk3</title>
<link rel="stylesheet" href="../css/hippo.css" type="text/css" media="screen" />
<style type="text/css">
label.error {
color: #FF0000;
}
</style>
</head>
<body>
<div id="onlineboeking">
<form action="../templates/boekingformulier2.php" method="post" name="example">
<p>
<label
for="tocht"
class="field <?php if(!empty($_SESSION['errors']['tocht'])) echo 'error'; ?>"
>Tocht:</label>
<select id="tocht" name="tocht">
<?php
session_start();
$sql = "SELECT TOCHT FROM `hippotrail` ";
if(!$result = $mysqli->query($sql))
{
trigger_error('Fout in query: '.$mysqli->error);
}
if ($result->num_rows)
while($row = $result->fetch_assoc())
{
?>
<option value=" <?php echo $row['TOCHT']?> "> <?php echo $row['TOCHT'];
echo" </option>";
}
?>
</select>
</p>
<p>
<input name="submit" type="submit" class="lijnuit" value="Verzenden" />
</p>
</form>
</div>
</body>
</html>
Bovenstaand formulier werkt.
Het post de inhoud van het label tocht.
In het 2° formulier (hieronder) vang ik de inhoud van tocht als volgt op:
<?php
$tocht=$_POST['tocht']; ?>
$tocht wordt weergegeven in
><?php echo $tocht ?>:</label>
tot zover alles ok
Nu wil ik $tocht ook gebruiken in de query en dat werkt niet
$sql = "SELECT DATUM FROM `hippotrail` WHERE TOCHT ='$tocht' ";
Hieronder het volledige 2°formulier.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<?php include('bovenmenu.php'); ?>
<?php include('connect.php'); ?>
//ini_set('display_errors', 1);
//error_reporting(E_ALL);
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>verwerk3</title>
<link rel="stylesheet" href="../css/hippo.css" type="text/css" media="screen" />
<style type="text/css">
label.error {
color: #FF0000;
}
</style>
</head>
<body>
<?php
$tocht=$_POST['tocht']; ?>
<div id="onlineboeking">
<form action="../templates/verwerk3.php" method="post" name="example">
<p>
<label
for="datumtocht"
class="field <?php if(!empty($_SESSION['errors']['datumtocht'])) echo 'error'; ?>"
><?php echo $tocht ?>:</label>
<select id="datumtocht" name="datumtocht">
<?php
$sql = "SELECT DATUM FROM `hippotrail` WHERE TOCHT = '$tocht' ";
if(!$result = $mysqli->query($sql))
{
trigger_error('Fout in query: '.$mysqli->error);
}
if ($result->num_rows)
while($row = $result->fetch_assoc())
{
?>
<option value="<?php echo $row['DATUM']?>"><?php echo $row['DATUM'];
echo" </option>";
}
?>
</select>
</p>
<p>
<input name="submit" type="submit" class="lijnuit" value="Verzenden" />
</p>
</form>
</div>
</body>
</html>