Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

putting a php variable in a HTML form value

Tags:

html

php

I've got a php variable like so.. $name = $_REQUEST['name']; I'd like to put it in a HTML form field's value e.g in here.. <input type="text" name="name" value=(php variable here) /> How would I do so?

Thanks.

like image 681
Skizit Avatar asked Jul 23 '10 11:07

Skizit


People also ask

How set PHP variable in HTML?

PHP code cannot be nested within itself. echo "<? php echo 'foo' ?>" is going to print PHP code, not "foo". and even then, you're using the wrong type of quotes to allow embedding variables in text anyways.

How input a value in a variable in PHP?

In order to get an input value, you can use the htmlspecialchars() method and $_REQUEST variable. Note: The htmlspecialchars() method functions by converting special characters to HTML entities. The $_REQUEST variable is a built-in PHP variable that functions by getting data from the input field.

How can get HTML element value in PHP?

js"></script> </head> <body> <script type="text/javascript"> $. post('test. php',{'data': "value1"}); </script> <? php $data = $_POST['data']; print( "data is: $data" ); ?>


1 Answers

value="<?php echo htmlspecialchars($name); ?>"
like image 68
Quentin Avatar answered Oct 05 '22 23:10

Quentin