Hallo,
Simpel gezegd: Waarom werkt het onderstaande script niet!?
<?php error_reporting(E_ALL); ?>
<?
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Mail Formulier</title>
</head>
<body>
<?
$prijs_Nes = '50';
$prijs_Gameboy = '50';
$prijs_64 = '60';
$prijs_Gamecube = '105';
$prijs_DS = '120';
$prijs_Wii = '250';
$prijs_ps0 = '50';
$prijs_Ps1 = '80';
$prijs_Ps2 = '115';
$prijs_Ps3 = '599';
$prijs_Psp = '170';
$prijs_Xbox = '299';
$prijs_Xbox360 = '299';
$_SESSION['type'] = $_POST["type"];
$typenaam = '';
$prijs = '';
if ($_POST["type"] == "Nes") {
$typenaam = 'Nintendo Entertaining System';
$prijs = $prijs_Nes;
}
else if ($_POST["type"] == "Gameboy") {
$typenaam = 'Nintendo Gameboy';
$prijs = $prijs_Gameboy;
}
else if ($_POST["type"] == "64") {
$typenaam = 'Nintendo 64';
$prijs = $prijs_64;
}
else if ($_POST["type"] == "Gamecube") {
$typenaam = 'Nintendo Gamecube';
$prijs = $prijs_Gamecube;
}
else if ($_POST["type"] == "DS") {
$typenaam = 'Nintendo DS';
$prijs = $prijs_Ds;
}
else if ($_POST["type"] == "Wii") {
$typenaam = 'Nintendo Wii';
$prijs = $prijs_Wii;
}
else if ($_POST["type"] == "Ps0") {
$typenaam = 'Ps One';
$prijs = $prijs_Ps0;
}
else if ($_POST["type"] == "Ps1") {
$typenaam = 'Playstation 1';
$prijs = $prijs_Ps1;
}
else if ($_POST["type"] == "Ps2") {
$typenaam = 'Playstation 2';
$prijs = $prijs_Ps2;
}
else if ($_POST["type"] == "Ps3") {
$typenaam = 'Playstation 3';
$prijs = $prijs_Ps3;
}
else if ($_POST["type"] == "Psp") {
$typenaam = 'Playstation 3';
$prijs = $prijs_Psp;
}
else if ($_POST["type"] == "Xbox") {
$typenaam = 'Xbox';
$prijs = $prijs_Xbox;
}
else if ($_POST["type"] == "Xbox360") {
$typenaam = 'Xbox 360';
$prijs = $prijs_Xbox360;
}
echo $prijs_Wii;
echo $typenaam;
echo $prijs;
?>
</body>
</html>
Die variabelen worden in de vorige pagina aanroepen volgens het volgende:
<?
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Mail Formulier</title>
</head>
<body>
<?
if(!empty($_POST['verstuurja1']))
{ // Er is op de knop 'verstuur e-mail' gedrukt...
$pError = ''; // Een begin met de errors als die er zijn
$pI = 0; // Deze telt het aantal erros.
if(strlen($_POST['type']) < 2)
{ $pError .= '- Je hebt geen eigen spelcomputer ingevuld!<br>'; $pI++; }
if(!empty($pError))
{ // Als er dan toch errors zijn..
echo ($pI == 1) ? 'De volgende fout is opgetreden:<br>' : 'De volgende fouten zijn opgetreden:<br>'; // even kijken of het meervoud of enkelvoud is.
echo $pError; // echoën van de error(s)
}
else
{
$_SESSION['type'] = $_POST["type"];
$pShow = false; // formulier wordt niet weer getoond
header("Location: paginaja2.php");
}
}
// Kijken of er een waarde moet worden gegeven aan velden...
$pspelcomputer = $_POST['type'];
if(!isset($pShow))
{ // het formulier als $pShow niet bestaat.
?>
<form name="enquete" method="post" action="<?= $_SERVER['PHP_SELF']; ?>">
<table border="0" width="100%">
<tr>
<td width="1%" bgcolor="#9BE3F9" valign="top" bordercolor="#007095"><b>
<font face="Arial" color="#007095">3 </font></b></td>
<td bgcolor="#9BE3F9" colspan="2"><b><font face="Arial" color="#007095">
<font size="2">Welke spelcomputer heb je?.<br>
</font><i><font size="1">Als het er meerdere zijn, zou je dan alleen de
gegevens in wil vullen van de spelcomputer waarvan je het meeste gebruik
maakt?</font></i></font></b></td>
</tr>
<tr>
<td width="1%"> </td>
<td width="91%" bgcolor="#007095">
<table border="1" width="94%" bgcolor="#007095" cellspacing="0" bordercolor="#9BE3F9">
<tr>
<td width="11%" align="right" rowspan="6" valign="top"><b>
<font size="2" face="Arial" color="#9BE3F9">Nintendo
</font></b></td>
<td width="88%">
<input type="radio" style="background-color:#9BE3F9;border: 2 solid #0099CC;color:#007095;" onclick="disable()" value="Nes" name="type"><font size="2" face="Arial" color="#9BE3F9">(Super)
Nintento Entertaining System ((S)NES)</font></td>
</tr>
<tr>
<td width="88%">
<input type="radio" style="background-color:#9BE3F9;border: 2 solid #0099CC;color:#007095;" onclick="disable()" value="Gameboy" name="type"><font size="2" face="Arial" color="#9BE3F9">Gameboy
(Color)</font></td>
</tr>
// ETC. Etc. gaat verder allemaal hetzelfde als bovenstaande.
<tr>
<td width="1%"> </td>
<td colspan="2" align="right"><input style="background-color:#9BE3F9;border: 2 solid #0099CC;color:#007095;" type="submit" name="verstuurja1" value="Versturen"</td>
</tr>
</table>
</form>
<?
}
?>
</body>
</html>
Het enige wat hij wel doet is de regel 'echo $prijs_Wii';
Hij geeft ook de volgende foutmeldingen:
Notice: Undefined index: type in /usr/export/www/vhosts/funnetwork/hosting/annuh/paginaja2.php on line 28
Notice: Undefined index: type in /usr/export/www/vhosts/funnetwork/hosting/annuh/paginaja2.php on line 33
etc.. MAAR WAAROM? Ik dacht dat het zo wel klopte allemaal?
Ik heb het gevoel dat het niet helemaal goed gaat met de sessions maar waarom??
Alvast heel hartelijk bedankt!!
Simpel gezegd: Waarom werkt het onderstaande script niet!?
<?php error_reporting(E_ALL); ?>
<?
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Mail Formulier</title>
</head>
<body>
<?
$prijs_Nes = '50';
$prijs_Gameboy = '50';
$prijs_64 = '60';
$prijs_Gamecube = '105';
$prijs_DS = '120';
$prijs_Wii = '250';
$prijs_ps0 = '50';
$prijs_Ps1 = '80';
$prijs_Ps2 = '115';
$prijs_Ps3 = '599';
$prijs_Psp = '170';
$prijs_Xbox = '299';
$prijs_Xbox360 = '299';
$_SESSION['type'] = $_POST["type"];
$typenaam = '';
$prijs = '';
if ($_POST["type"] == "Nes") {
$typenaam = 'Nintendo Entertaining System';
$prijs = $prijs_Nes;
}
else if ($_POST["type"] == "Gameboy") {
$typenaam = 'Nintendo Gameboy';
$prijs = $prijs_Gameboy;
}
else if ($_POST["type"] == "64") {
$typenaam = 'Nintendo 64';
$prijs = $prijs_64;
}
else if ($_POST["type"] == "Gamecube") {
$typenaam = 'Nintendo Gamecube';
$prijs = $prijs_Gamecube;
}
else if ($_POST["type"] == "DS") {
$typenaam = 'Nintendo DS';
$prijs = $prijs_Ds;
}
else if ($_POST["type"] == "Wii") {
$typenaam = 'Nintendo Wii';
$prijs = $prijs_Wii;
}
else if ($_POST["type"] == "Ps0") {
$typenaam = 'Ps One';
$prijs = $prijs_Ps0;
}
else if ($_POST["type"] == "Ps1") {
$typenaam = 'Playstation 1';
$prijs = $prijs_Ps1;
}
else if ($_POST["type"] == "Ps2") {
$typenaam = 'Playstation 2';
$prijs = $prijs_Ps2;
}
else if ($_POST["type"] == "Ps3") {
$typenaam = 'Playstation 3';
$prijs = $prijs_Ps3;
}
else if ($_POST["type"] == "Psp") {
$typenaam = 'Playstation 3';
$prijs = $prijs_Psp;
}
else if ($_POST["type"] == "Xbox") {
$typenaam = 'Xbox';
$prijs = $prijs_Xbox;
}
else if ($_POST["type"] == "Xbox360") {
$typenaam = 'Xbox 360';
$prijs = $prijs_Xbox360;
}
echo $prijs_Wii;
echo $typenaam;
echo $prijs;
?>
</body>
</html>
Die variabelen worden in de vorige pagina aanroepen volgens het volgende:
<?
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Mail Formulier</title>
</head>
<body>
<?
if(!empty($_POST['verstuurja1']))
{ // Er is op de knop 'verstuur e-mail' gedrukt...
$pError = ''; // Een begin met de errors als die er zijn
$pI = 0; // Deze telt het aantal erros.
if(strlen($_POST['type']) < 2)
{ $pError .= '- Je hebt geen eigen spelcomputer ingevuld!<br>'; $pI++; }
if(!empty($pError))
{ // Als er dan toch errors zijn..
echo ($pI == 1) ? 'De volgende fout is opgetreden:<br>' : 'De volgende fouten zijn opgetreden:<br>'; // even kijken of het meervoud of enkelvoud is.
echo $pError; // echoën van de error(s)
}
else
{
$_SESSION['type'] = $_POST["type"];
$pShow = false; // formulier wordt niet weer getoond
header("Location: paginaja2.php");
}
}
// Kijken of er een waarde moet worden gegeven aan velden...
$pspelcomputer = $_POST['type'];
if(!isset($pShow))
{ // het formulier als $pShow niet bestaat.
?>
<form name="enquete" method="post" action="<?= $_SERVER['PHP_SELF']; ?>">
<table border="0" width="100%">
<tr>
<td width="1%" bgcolor="#9BE3F9" valign="top" bordercolor="#007095"><b>
<font face="Arial" color="#007095">3 </font></b></td>
<td bgcolor="#9BE3F9" colspan="2"><b><font face="Arial" color="#007095">
<font size="2">Welke spelcomputer heb je?.<br>
</font><i><font size="1">Als het er meerdere zijn, zou je dan alleen de
gegevens in wil vullen van de spelcomputer waarvan je het meeste gebruik
maakt?</font></i></font></b></td>
</tr>
<tr>
<td width="1%"> </td>
<td width="91%" bgcolor="#007095">
<table border="1" width="94%" bgcolor="#007095" cellspacing="0" bordercolor="#9BE3F9">
<tr>
<td width="11%" align="right" rowspan="6" valign="top"><b>
<font size="2" face="Arial" color="#9BE3F9">Nintendo
</font></b></td>
<td width="88%">
<input type="radio" style="background-color:#9BE3F9;border: 2 solid #0099CC;color:#007095;" onclick="disable()" value="Nes" name="type"><font size="2" face="Arial" color="#9BE3F9">(Super)
Nintento Entertaining System ((S)NES)</font></td>
</tr>
<tr>
<td width="88%">
<input type="radio" style="background-color:#9BE3F9;border: 2 solid #0099CC;color:#007095;" onclick="disable()" value="Gameboy" name="type"><font size="2" face="Arial" color="#9BE3F9">Gameboy
(Color)</font></td>
</tr>
// ETC. Etc. gaat verder allemaal hetzelfde als bovenstaande.
<tr>
<td width="1%"> </td>
<td colspan="2" align="right"><input style="background-color:#9BE3F9;border: 2 solid #0099CC;color:#007095;" type="submit" name="verstuurja1" value="Versturen"</td>
</tr>
</table>
</form>
<?
}
?>
</body>
</html>
Het enige wat hij wel doet is de regel 'echo $prijs_Wii';
Hij geeft ook de volgende foutmeldingen:
Notice: Undefined index: type in /usr/export/www/vhosts/funnetwork/hosting/annuh/paginaja2.php on line 28
Notice: Undefined index: type in /usr/export/www/vhosts/funnetwork/hosting/annuh/paginaja2.php on line 33
etc.. MAAR WAAROM? Ik dacht dat het zo wel klopte allemaal?
Ik heb het gevoel dat het niet helemaal goed gaat met de sessions maar waarom??
Alvast heel hartelijk bedankt!!