Tony
Tony

Reputation: 513

Auto Filled textbox in php

I am a beginner. I created a simple generator of pictures and I would like that when he was generate code in the text box and not as plain text. Please help.

So it should look like: https://i.sstatic.net/cXT7X.jpg

Upvotes: 0

Views: 2070

Answers (4)

Utkarsh Dixit
Utkarsh Dixit

Reputation: 4275

I didn't understand what i am saying but if you want to set the text inside the text input than you should use value element in input tag. For example your code should look like this :-

<input type="text" value="<?php echo $yourvalue;?>" />

Hope this works for you.

Upvotes: 0

Shujaat
Shujaat

Reputation: 691

Just keep in mind that PHP generates HTML that the browser parses...

<input type="text" name="url" value="<?php echo htmlspeciachars($url,ENT_QUOTES); ?>">

its important to use ENT_QUOTES or some other kind of data filter to avoid XSS.

Upvotes: 0

m1k1o
m1k1o

Reputation: 2364

Use basic HTML FORM elements with readonly attribute.

<textarea readonly><?php echo $code; ?></textarea>

Upvotes: 0

webNeat
webNeat

Reputation: 2828

I suppose you are doing something like

echo $code;

to show your code; if this is the case so you only have to do it like this :

echo '<input type="text" name="my_code" value="' . $code . '">';

or

echo '<textarea name="my_code">' . $code . '</textarea>';

That's it

Upvotes: 1

Related Questions