Skip to main content
Participant
March 15, 2011
Question

php won't wrap

  • March 15, 2011
  • 1 reply
  • 825 views

I have written a form and the subsequent php page.  However, when the text moves from the html page it doesn't wrap in the php page despite the echo command within the code.

<form  action="expert page ethics 1.php" method="post">

What steps lead up to  the unethical behavior: <br />
<textarea name="txtInput1" rows="10"  cols="60"></textarea><br />
What steps should you take to  avoid the delema? <br />
<textarea name="txtInput2" rows="10"  cols="60"></textarea><br />
<input type="submit"  value="Click here to compare your answers with those of the  experts"/>

</form>

<h3>Your  Response</h3>
<h5>Steps Leading up to Unethical  behavior</h5><br/>
<?php echo  $_POST["txtInput1"];?><br/>
<h5>What steps should you take to  avoid the delema?</h5><br/>

<?php echo  $_POST["txtInput2"];?><br/>
</div>
This topic has been closed for replies.

1 reply

Günter_Schenk
Inspiring
March 15, 2011

dmaughan23 wrote:

What steps should you take to  avoid the delema?

Apply the PHP function nl2br, example:

<?php echo nl2br($_POST["txtInput2"]);?>

Participant
March 15, 2011

Thanks for the answer, but it is still not working.  It stills doesn't wrap.  Any other helpful suggestions?

This is my code with your hint included.

<?php  echo nl2br($_POST["txtInput1"]);?><br/>
Participant
March 15, 2011

dmaughan23 wrote:

Thanks for the answer, but it is still not working.  It stills doesn't wrap.

Out of sheer curiosity I made myself 2 pages which use the very same code you provided and applied the nl2br function -- guess what: it does indeed wrap

On a side note: it´s unrelated to your issue, but document (and other file) names such as "expert page ethics 1.php" can be problematic with Linux/Unix hostings due to the white spaces -- better replace them with underscores for instance, example:

expert_page_ethics_1.php


Thanks for the side note.  As you can probably tell I'm somewhat of a novice.  The wrap problem I'll have to play with it a bit.