variable not printing

Hello all,

as you can tell i am still new at php. i am learning from a book i bought. now i have run across a problem and would like your help.

i am just doing the simple hi user exercise but i cannot figure out what is going wrong. i enter a name in the text field and hit submit but on the next page it just says “Hi there, !”

this is the php code

[code]

Hi User

Hi User

PHP program that receives a value from "whatsName"

[/code]

can anyone tell me what is wrong? thank you in advance

entropy,

The reason you’re receiving ‘Hi there, !’ is because $userName hasn’t been set to anything. The example below will print off ‘Hi there, Harry!’

Hope this helps.

-boobay

[code]

Hi User

Hi User

PHP program that receives a value from "whatsName"

[/code]

thank you boobay, now how can i integrate this into a form such as here:

http://entropy.vndv.com/learning/chapte … sName.html

as you can see you still enter a name in the text field and hit submit but on the next page it just says “Hi there, !”

any ideas?

thank you :D

When I go to that page I get the following:

Parse error: syntax error, unexpected '[' in /www/vndv.com/e/n/t/entropy/htdocs/learning/chapter_2/hiUser.php on line 11

What I think you’re trying to do is submit a value through a form and then use it in a PHP script:

<?php
echo 'Hello '.$_POST['newvalue'].'!<br><br>';
?>

<form method='post' action='thispage.php'>
Type new value:
<input type='text' name='nevwalue' size='12'><br>
<input type='submit' value='Submit'>
</form>
Sponsor our Newsletter | Privacy Policy | Terms of Service