Я начинаю и сам учащийся. Это может быть простой вопрос, но это создает для меня некоторые проблемы. Кажется, я что-то пропустил.напечатать значение textarea,
Когда я пишу текст в textarea
и нажмите Найти и заменить кнопку (оставляя другие два поля пустыми), значение захваченное из textarea
должен появиться в самом и сообщение об ошибке textarea
должны появляться за пределами textarea
. textarea
не должен быть пустым. Я думаю, что сообщение работает нормально.
Я не уверен, что проблема связана с кнопкой или действием = '' в форме.
<?php
//find and replace string
//using str_replace(), takes three parameters, $findword, $wordtoreplace, $userinput
if(isset($_POST['text']) && isset($_POST['find']) && isset($_POST['replace'])){
$paragraph=nl2br(htmlentities($_POST['text']));
$find_string=$_POST['find']; //assign the value to be found to the variable
$replace_string=$_POST['replace']; //assign the value to be replaced
if(empty($paragraph)){
echo 'No text to search for.';
}
elseif(empty($find_string)){
echo 'Enter some text to find.';
}
elseif(empty($replace_string)){
echo 'Enter some text to replace with.';
}
else{
echo str_replace($find_string, $replace_string, $paragraph);
}
}
?>
<form action='' method='POST'>
<textarea name='text' rows=20 cols=100 value='<?php echo $paragraph; ?>'></textarea
<br />
<label>Search For</label>
<input name='find' value='<?php echo $find_string; ?>'></input>
<br />
<label>Replace with</label>
<input name='replace' value='<?php echo $replace_string; ?>'></input>
<br />
<button>Find and Replace</button>
</form>