printing php variables on html forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Aundry
Forum Newbie
Posts: 2
Joined: Sat Jul 27, 2002 4:14 pm
Location: Chicago

printing php variables on html forms

Post by Aundry »

Well, the title is somewhat self vague, but basically, I want to use a php echo to print the values of the variable of an html form. Php is installed on my system, but when I run the code the spaces where I put in a $variablename, the html and other text comes out, but it doesn't print the value of the variable. How can I fix this, or is there something I can do?

This is an example of the form source:
<form action="code.php" method=post>
<input type=text name="variable1" value="blue">
<input type=submit value="send">
</form>

This is the php code that I send the results of the above form:
<?php
echo "I like $variable1";
?>

If you know whats wrong, please help me.
trevorj
Forum Newbie
Posts: 1
Joined: Sat Jul 27, 2002 9:11 pm
Location: right behind you.
Contact:

Post by trevorj »

try

Code: Select all

<?php 
echo "I like ".$_REQUEST&#1111;'variable1']; 
?>
:mrgreen:
newgent
Forum Newbie
Posts: 2
Joined: Sun Jul 28, 2002 1:42 am
Location: I**

Post by newgent »

maybe $_POST['variable1'] is better for that condition ?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Aundry
Forum Newbie
Posts: 2
Joined: Sat Jul 27, 2002 4:14 pm
Location: Chicago

thanks

Post by Aundry »

thank you! that helped ^_^
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

That's why it's a sticky... (and says 'Before post read')

Mac
Post Reply