Jump to content


Photo

Displaying variables in a text box


  • Please log in to reply
5 replies to this topic

#1 ADR3

ADR3
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 06 September 2006 - 03:12 PM

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;

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 September 2006 - 03:55 PM

You mean this code:
echo "Logged In As: ".$Username;

Thats fine. Whats wrong with it.

#3 ADR3

ADR3
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 06 September 2006 - 04:15 PM

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

#4 pikemsu28

pikemsu28
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts

Posted 06 September 2006 - 04:17 PM

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:
<?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>
this will display the variable $name in the text box.  If this isn't what you are looking for.....sorry!

#5 garces

garces
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 08 September 2006 - 10:08 AM

// I think you have to create a file which willl be your page form

/*save this as input.html */

<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;
?>



#6 ADR3

ADR3
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 08 September 2006 - 12:00 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users