![]() |
|
[PHP] User outputted text - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: PHP (https://sinister.li/Forum-PHP) +--- Thread: [PHP] User outputted text (/Thread-PHP-User-outputted-text) |
[PHP] User outputted text - FrostByte_mybb_import5923 - 06-11-2011 Hey everyone, here i a very simple html/php code which allows the user to print what ever text is entered. PHP Code: <html>
<body>
<form action='test.php' method='POST'>
Text Area: </br><input type="text" size="65" rows="2"; maxlength="250" name="output"/>
<input type='submit' name='submit' value='Post'><br><br>
<?php
$submit = strip_tags($_POST['submit']);
$output = strip_tags($_POST['output']);
if ($submit) {
echo $output;
}
?>
</body>
</html>
Just save the file as test.php and run it, it is a very good code for beginners to use html and php together. RE: [PHP] User outputted text - The Alchemist - 08-15-2012 Simple code... Its fine but I think you should change this part : PHP Code: <?php
$submit = strip_tags($_POST['submit']);
$output = strip_tags($_POST['output']);
if ($submit) {
echo $output;
}
?>TO : PHP Code: <?php
if(isset($_POST['submit']) && isset($_POST['output']))
{
$output = strip_tags($_POST['output']);
echo $output;
}
?>No need of using another variable for $_POST['submit'].... |