undefined variable problem...

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Mazerman
New php-forum User
New php-forum User
Posts: 12
Joined: Sun Jan 26, 2003 2:57 pm
Location: Sweden

undefined variable problem...

Postby Mazerman » Sun Jan 26, 2003 3:30 pm

I have installed PHP v4.3 on my computer with WinXP which runs IIS. When I runs my PHP-files it works fine until I starts to use variables, with forms. For an example look at this simple code:

Code: Select all

// ex11.htm
<html>
<head>
</head>
<body>
<form action="ex11.php" method="get">
Namn: <input type="text" size="10" name="namn"><br>
<input type="submit" value="skicka"></form>
</body>
</html>

//ex11.php
<html>
<head>
</head>

<body>
<?php
   echo "Your name is $namn ";
?>
</body>
</html>


When pressing on the button in the htm site I get the error message:
Notice: Undefined variable: namn in c:\inetpub\wwwroot\ex11.php on line 9
Your name is


So my question is why doesn't it work, what am I doing wrong...
Would be thankful for an answear
/Mazerman

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Tue Jan 28, 2003 3:34 pm

Code: Select all

//ex11.php
<html>
<head>
</head>

<body>
<?php
   echo "Your name is ".$HTTP_GET_VARS["namn"];
?>
</body>
</html>

Try this one
:)


Return to “PHP coding => General”

Who is online

Users browsing this forum: Baidu [Spider], Yahoo [Bot] and 2 guests