-2

I want to get value from php variable to review it in textbox

what I have to write in "value":

<input type="text" name="name3" size="25" maxlength="50" value=""> name:
Mike B
  • 31,886
  • 13
  • 87
  • 111
Husain
  • 11
  • 2
  • 4
  • 3
    I'll give my upvote to the first person thinking of doing a `htmlspecialchars()` on the output. :) – Pekka Aug 08 '10 at 19:37
  • I'd just like to point out that 16 seconds isn't enough time to read that comment and answer the question ;) – Quentin Aug 08 '10 at 19:38
  • 2
    possible duplicate of [How can I set the value of a textbox through PHP?](http://stackoverflow.com/questions/1484816/how-can-i-set-the-value-of-a-textbox-through-php) – Felix Kling Aug 08 '10 at 19:41
  • 1
    To use php you first need to learn php. – p4bl0 Aug 08 '10 at 19:51

2 Answers2

1
<input type="text" 
       name="name3" 
       size="25" 
       maxlength="50" 
       value="<?php echo htmlspecialchars($variable); ?>">
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Sorry for the late comment, but I just want to ask if htmlspecialchars will also work if you do the same in the textbox name. ' value="hello">' , for example. Thanks. – xjshiya Jan 10 '13 at 01:03
  • Only for some value of work that doesn't protect against XSS. You need to quote the attribute values. `name=""` would be fine. – Quentin Jan 10 '13 at 09:16
0
<input type="text" name="name3" size="25" maxlength="50" value="<?php echo $variable; ?>">
CrayonViolent
  • 32,111
  • 5
  • 56
  • 79