By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,971 Members | 1,467 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,971 IT Pros & Developers. It's quick & easy.

problem with learning PHP

P: n/a
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>
</form>
<?php
if($verzenden){
echo "<b>Hartelijk welkom, $voornaam $achternaam.</b>";
}
?>

is my installation wrong of PHP ?

did I forget some source ?

thanks,

Jonay
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
Jul 17 '05 #2

P: n/a

"Jonay Herrera" <jo***********@pandora.be> wrote in message
news:41**************************@posting.google.c om...
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>
</form>
<?php
if($verzenden){
echo "<b>Hartelijk welkom, $voornaam $achternaam.</b>";
}
?>

is my installation wrong of PHP ?

did I forget some source ?

thanks,

Jonay

Hi,

you can try it also with method="post" or just send verzenden as hidden
field (it must be between <form> and </form> tags):
<input type=hidden name=verzenden value=1>

It's a small workaround, but it should work

Lot of fun learning PHP.

Regards,
Damir
Jul 17 '05 #3

P: n/a
With total disregard for any kind of safety measures "Damir
Mehmedovic" <sr**************@gmx.net> leapt forth and uttered:
It's a small workaround


Completly wrong though.

--
There is no signature.....
Jul 17 '05 #4

P: n/a
Go into php.ini and turn off E_NOTICE.

Uzytkownik "Jonay Herrera" <jo***********@pandora.be> napisal w wiadomosci
news:41**************************@posting.google.c om...
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>
</form>
<?php
if($verzenden){
echo "<b>Hartelijk welkom, $voornaam $achternaam.</b>";
}
?>

is my installation wrong of PHP ?

did I forget some source ?

thanks,

Jonay

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.