Jump to content

Archived

This topic is now archived and is closed to further replies.

ADR3

Displaying variables in a text box

Recommended Posts

I am very new to all this I have been struggling to work out or find anyway to display variables in a text box once declared.  Could someone please edit the code below to achieve such a simple thing.

thanks alot

ADR3

echo "Logged In As: ".$Username;

Share this post


Link to post
Share on other sites
You mean this code:
[code=php:0]echo "Logged In As: ".$Username;[/code]

Thats fine. Whats wrong with it.

Share this post


Link to post
Share on other sites
That only echos it to the top left corner of page - how do you display the variable value in a text box which (which could be anywhere on page or in layer etc)

thanks again

ADR3

Share this post


Link to post
Share on other sites
I could be all wrong but i think you are wanting to display the variable in the Text field box, which can be accomplished like this:
[code]
<?php $name = 'TESTING'; ?>
<form id="form1" name="form1" method="post" action="">
  <label>Logged in as:
  <input type="text" name="textfield" value="<?php echo $name; ?>"/>
  </label>
</form>
[/code]
this will display the variable $name in the text box.  If this isn't what you are looking for.....sorry!

Share this post


Link to post
Share on other sites
// I think you have to create a file which willl be your page form

/*save this as [b]input.html[/b] */

<form method="post" action="display.php">
  <label>Logged in as:
  <input type="text" name="username" value="<?php echo $name; ?>"/>
  </label>
</form>


//then create another file and save as display.php which will be your script

<?php

        $username=$_POST['username'];

        echo "Logged In as ".$username;
?>

Share this post


Link to post
Share on other sites
thanks guys for the help - it now half works which is better than what it was - im pretty sure i can go on from here

thanks again

ADR3

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.