Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

php won't wrap

New Here ,
Mar 15, 2011 Mar 15, 2011

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>
TOPICS
Server side applications
834
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 15, 2011 Mar 15, 2011

dmaughan23 wrote:

What steps should you take to  avoid the delema?

Apply the PHP function nl2br, example:

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 15, 2011 Mar 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/>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 15, 2011 Mar 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 15, 2011 Mar 15, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 16, 2011 Mar 16, 2011

I was able to make the coding work.  Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 16, 2011 Mar 16, 2011

dmaughan23 wrote:

I was able to make the coding work.

Can you explain what you did to make it work, so that other users may get a clue when struggeling with similar issues ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 16, 2011 Mar 16, 2011

It is a little embarrassing.  My coding was working fine, as well as yours.  To test my wrap I was just holding one key down and letting it repeat.

Using your coding nl2br I was on the php website you provided and the "line break" finally click and I realized I was not giving my code a chance to find the line break.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 16, 2011 Mar 16, 2011
LATEST

If I started talking about the embarassing PHP coding moments I had, I could go on and on

Thanks for sharing, much appreciated !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines