Jonay Herrera wrote:
hello,
I'm trying to learn the basics of PHP, but when I try to
run a little simple script I received a error on my screen:
Notice: Undefined variable: verzenden in c:\program files\apache
group\apache\htdocs\test\formulier1.php on line 7
this is the source:
<form name="formulier1" action="formulier1.php" method="get">
Voer alstublieft uw voornaam in: <input type=text
name=voornaam><br><br>
Voer alstublieft uw achternaam in: <input type=text
name=achternaam><br><br>
<input type=submit name=verzenden>
Better would be:
<input type=submit value="verzenden">
and check in the following PHP for the existance of some variables.
</form>
<?php
if($verzenden){
Better would be to check IF a certain variable is send to this page.
Use isset() for this.
So:
if (isset($_GET["voornaam"])
echo "<b>Hartelijk welkom, $voornaam $achternaam.</b>";
}
?>
is my installation wrong of PHP ?
did I forget some source ?
thanks,
Jonay
But more important is this: You expect PHP to create the variables you send
with your form to be automatically created, eg: you expect the variable
$voornaam to be created JUST because you send it.
This used to be true for older versions of PHP, but (luckily) they changed
the default behaviour of PHP.
This is done in the php.ini under the name of: register_globals
here is a piece out of php.ini:
; You should do your best to write your scripts so that they do not require
; register_globals to be on; Using form variables as globals can easily
lead
; to possible security problems, if the code is not very well thought of.
register_globals = Off
So, I guess you have register_globals set to off too, as it should be.
Just use $_GET["varnamehere"] and $_POST["varnamehere"] to retrieve the
values.
Regards,
Erwin