Reputation: 54
<body onload="cmdform.command.focus()">
<form method="POST" action="#" name="cmdform">
<textarea style="width:100%; height:90%; background:black; color:green;" name="textarea" cols="20" >
<?php
$name="My Name";
if (isset($_POST['submit'])){
if (!empty($_POST['command'])){
echo $me = $_POST['textarea'];
echo "\n";
echo $_POST['command'];
}else{
echo $me = $_POST['textarea'];
}
}
?>
</textarea>
<input type="text" name="command">
<input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="B2">
</form></body>
When I enter $name in textbox("command") 'My Name' should display in textarea
Upvotes: 0
Views: 43
Reputation: 19545
You can solve this with a simple str_replace()
call.
$content = str_replace('$name', $name, $content);
Or you use an if()
statement to check if the content is exactly the string "$name"
.
if ($_POST['command'] == '$name') {
$content = $name;
}
Upvotes: 1