Reputation: 513
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
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
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
Reputation: 2364
Use basic HTML
FORM
elements with readonly
attribute.
<textarea readonly><?php echo $code; ?></textarea>
Upvotes: 0
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