Weird simple html and PHP problem

02/15/2014 20:46 mlukac89#1
I have problem with this script, script working fine and send mails but since i added this code textarea is acting strange it populate first few spaces with blank space, same on localhost and on live server

PHP Code:
<textarea><?php if (isset($_POST['body'])) { echo htmlentities($_POST['body']); } ?></textarea>
I tried to put it like this too and problem is still here :(

PHP Code:
<textarea value="<?php if (isset($_POST['body'])) { echo htmlentities($_POST['body']); } ?>"></textarea>
Im using that code so that script remember what user entered when error ocurr, that inputs save values, but problem is only on this field.

You can look here [Only registered and activated users can see links. Click Here To Register...] what i talk about, go in Message area, click inside and press CTRL + a and you will see what problem is its populated with blank space :)



PHP Code:
<form action="contact.php" method="POST">
    <ul>
        <li><label><strong>Email</strong></label></li>
        <li><input type="email" name="email" placeholder="Email" 
        value="<?php if (isset($_POST['email'])) { echo htmlentities($_POST['email']); } ?>"></li>
        <li>&nbsp;</li>
        <li><label><strong>Title</strong></label></li>
        <li><input type="text" name="title" placeholder="Title" 
        value="<?php if (isset($_POST['title'])) { echo htmlentities($_POST['title']); } ?>"></li>
        <li>&nbsp;</li>
        <li><label><strong>Message</strong></label></li>
        <li><textarea name="body" cols="40" rows="8">
        <?php if (isset($_POST['body'])) { echo htmlentities($_POST['body']); } ?>
        </textarea></li>
        <li>&nbsp;</li>
        <li><label><strong>Security check</strong></label></li>
        <li>5 + 3 = <input type="text" name="securecheck"></li>
        <li><input type="submit" name="send" value="Send" class="submit-button"></li>
    </ul>
</form>
02/16/2014 01:10 adistoe#2
Try this:
PHP Code:
<li><textarea name="body" cols="40" rows="8">
<?php echo htmlentities(@$_POST['body']); ?>
</textarea></li>
02/16/2014 11:59 mlukac89#3
still doesn't work i dont know why :( on other fileds works normal

Problem solved :

need to be like this in 1 line

PHP Code:
<textarea name="body" cols="40" rows="8"><?php if (isset($_POST['body'])) { echo htmlentities($_POST['body']); } ?></textarea>

and i was make it in 3 line like this to see code better

PHP Code:
<textarea name="body" cols="40" rows="8">
<?php if (isset($_POST['body'])) { echo htmlentities($_POST['body']); } ?>
</textarea>