PDA

View Full Version : $_POST and the Break Tags


curb
07-15-2006, 01:04 AM
After I submit my form, the textarea generates a <br /> for every line break. It doesn't show up on localhost but it does on my host.

<form action="" method="post">
<div class="text"><strong>URL</strong></div>
<input name="link" type="text" />
<input type="submit" name="submit" value="Generate" class="bginput">
</form>


<textarea name="textarea" onClick="this.focus();this.select()">
<?php
$link = $_POST['link'];
if ($link == "") {
echo "Please fill out the form.";

} else {
echo "Submitted.
Your URL is ".$_POST['link']."";
}
?>
</textarea>

Any help would be appreciated :)

ns1987
07-15-2006, 08:07 AM
Something with your hosts settings. Did you try asking them? (I personally don't know which one it is, maybe someone else does. :()

curb
07-17-2006, 03:29 AM
Is there a way I can remove the <br /> tag?

ns1987
07-17-2006, 07:46 AM
To remove all <br /> tags from the $_POST variable:

str_replace('<br />', '', $_POST);

But if you have an older version of PHP, it might not work and you might have to loop through and apply str_replace.

paulq
07-17-2006, 03:01 PM
As a last resort you could use CSS to change the way that the breaks are displayed. For example, if you give your text area the class name "textAreaClass" your CSS could look like this:

.textAreaClass br { display: none; }

This would stop all the <br /> in your you text area with class name "textAreaClass" from displaying.