Hi all,
I'm brand-new at this, but I think I have an odd problem. :-(
I'm using checked php code that work fine on other pc's, but with my installation I get no output to the screen.
When I use normal echo statements like the "hello world" example, all works fine, but when I'm using POST (or $_SERVER) in a file, I get no data at all.
I'm using php4 with mysql from the install-package php-dev.
Did not change any settings or ini's and all files are in the right place.
Anyone who can tell me if this is a PHP config error, or a browser error or whatever and how I can solve this?
Best regards,
Mandel, The Netherlands
Here are two examples that will not produce output to my screen:
getting browsertype:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Browserdetectie</title>
</head>
<body>
<?php
$browser = $_SERVER["HTTP_USER_AGENT"];
if (strpos($browser, "MSIE")){
//code voor doorsturen naar IE-specifieke pagina's
echo ("<b>Welkom, u gebruikt Internet Explorer (volledige versie: $browser</b>");
}else{
// code voor doorsturen naar andere pagina's of testen op
// andere browser, platform, versie, enzovoort
echo ("<b>Welkom, u de volgende browser: $browser</b>");
}
?>
</body>
</html>
Second example (simple calculator):
<html>
<head>
<title>Twee getallen optellen (3)</title>
</head>
<body>
<?php if (isset($POST["flag"]))
{
// formulier heeft zichzelf aangeroepen; initialisatie
$getal1 = $POST["getal1"];
$getal2 = $POST["getal2"];
$bewerking = $POST["bewerking"];
$totaal = 0 ;
$boodschap = "";
switch ($bewerking){
case 1: // optellen gekozen
$totaal = $getal1 + $getal2;
$operator = " + ";
break;
case 2: // aftrekken
$totaal = $getal1 - $getal2;
$operator = " - ";
break;
case 3: // delen
$totaal = $getal1 / $getal2;
$operator = " / ";
break;
case 4: // vermenigvuldigen
$totaal = $getal1 * $getal2;
$operator = " * ";
break;
default:
}
echo ("<h1>$getal1 $operator $getal2 = $totaal</h1>\n");
echo ("<a href=\"" . $_SERVER["PHP_SELF"] . "\">Nieuwe berekening uitvoeren</a>");
}
else{
// geen berekening gekozen, formulier op het scherm tonen
?>
<form name="form1" method="post" action="<?php echo($_SERVER["PHP_SELF"]);?>">
getal 1: <input name="getal1" type="text"> <br>
getal 2: <input name="getal2" type="text"> <br>
<input type="Radio" name="bewerking" value="1"> Optellen(+)
<input type="Radio" name="bewerking" value="2"> Aftrekken(-)
<input type="Radio" name="bewerking" value="3"> Delen(/)
<input type="Radio" name="bewerking" value="4"> Vermenigvuldigen(*)
<input type="Hidden" name="flag" value="1">
<hr>
<input type="submit" name="Submit" value="Bereken">
<input name="Reset" type="reset" id="Reset" value="Leegmaken">
</form>
<?php }?>
</body>
</html>