Jump to content

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;
Link to comment
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!
Link to comment
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;
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.