Dear NG'ers,
I try to learn PHP and found several examples for a HTML form to add a
record to a database. I started out with just checking the workings of a
html form with PHP and am completely confused with the workings.
If I use GET to send the form I can clearly see the information exists. But
the second time the page is requested the action i expect (no show of the
form) is not executed.
The POST to send the form results in the same behavior.
I changed the location of the function to write the form from the body to
the head section and there is no difference in the behavior (as expected)
This is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head><title>IS SET1 testen</title>
<?php
function schrijfForm() {
print "<form action=\"isset_ test1.php\" method=\"POST\" >\n" ;
print "Voer nieuwe tekst in... \t" ;
print "<input type=\"text\" name=\"tekst1\" >\n " ;
print "<input type=\"submit\" value=\"Voeg Toe!\"
name=\"ditform\ ">\n</form>\n" ;
}
?>
</head>
<body>
<?php
if ( isset( $ditform ) ) {
print "\$ditform is gezet: \t$ditform\n" ;
print "\$tekst1 is gezet: \t$tekst1\n" ;
} else {
print "HET BESTAAT NIET\n" ;
schrijfForm() ;
}
?>
<p>wat tekst </p>
</body>
</html>
I would appreciate some explanation of why this code doesn't work?
tia
pablo k
I try to learn PHP and found several examples for a HTML form to add a
record to a database. I started out with just checking the workings of a
html form with PHP and am completely confused with the workings.
If I use GET to send the form I can clearly see the information exists. But
the second time the page is requested the action i expect (no show of the
form) is not executed.
The POST to send the form results in the same behavior.
I changed the location of the function to write the form from the body to
the head section and there is no difference in the behavior (as expected)
This is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head><title>IS SET1 testen</title>
<?php
function schrijfForm() {
print "<form action=\"isset_ test1.php\" method=\"POST\" >\n" ;
print "Voer nieuwe tekst in... \t" ;
print "<input type=\"text\" name=\"tekst1\" >\n " ;
print "<input type=\"submit\" value=\"Voeg Toe!\"
name=\"ditform\ ">\n</form>\n" ;
}
?>
</head>
<body>
<?php
if ( isset( $ditform ) ) {
print "\$ditform is gezet: \t$ditform\n" ;
print "\$tekst1 is gezet: \t$tekst1\n" ;
} else {
print "HET BESTAAT NIET\n" ;
schrijfForm() ;
}
?>
<p>wat tekst </p>
</body>
</html>
I would appreciate some explanation of why this code doesn't work?
tia
pablo k
Comment