You have to echo the value to display it:
<input type="text" size="18" value="<?php echo htmlspecialchars($user, ENT_QUOTES, 'UTF-8'); ?>" />
As you can see I also used htmlspecialchars() to prevent against XSS attacks.
Also please, don't use mysql_* functions for new code. They are no longer maintained and the community has begun the deprecation process. See the red box? Instead you should learn about prepared statements and use either PDO or MySQLi. If you can't decide, this article will help to choose. If you care to learn, here is a good PDO tutorial.
Another thing I notice is that you are using the global keyword. It would be better to inject the connection as a parameter in the function:
function SaveHTML($cn){
$content=mysql_real_escape_string( $_POST["html"],$cn);
$url=mysql_real_escape_string("http://www.google.com/",$cn);
mysql_query("Insert into HTML(content,URL) values('$content','$url')");
}
Edit (Death):
What I wanted is the folllowing:
Assume you have a varivle $user and piece of HTML code like below:
$html = <<<'Death'
<input type="text" size="18" value="$user" />
Death;
now, If I save this variable ($html) to a database and in another page I send this html to user, what should I do to the $user in html code have value of $user in second page?
Answer:
I saved string (as it is) to database and then used eval() function to replace the $user with it's value!
EDIT PeeHaa
Note that in most cases it is considered bad practice to have HTML in your database (unless you). I'm also not that happy about with eval() stuff (which is always bad practice).
mysql_queryby concatenating SQL code with data read from the network. That is a hotbed for SQL injections. Useprepareinstead: php.net/manual/de/pdo.prepared-statements.phpmysql_real_escape_string. php.net/manual/en/book.pdo.php. EDIT: dang, got me by 29 seconds, I'll leave the PDO link up for reference.