Page 1 of 1

text box

Posted: Thu Sep 18, 2003 6:33 pm
by FinalAeon
Here's the issue, it'll take a long time to explain yet I beleive it's gunna have a simple answer. I have an HTML text box that when they hit "submit" it uses a php script i made and saves it as the file they specified onto my site.

Note: Please ignore the periods.

---------------------------------------------------------------------------------
.................. ____________
File Name: |____________|

Text:
____________________________________
|.......................................................................|
|.......................................................................|
|.......................................................................|
|.......................................................................|
|.......................................................................|
|___________________________________|

----------------------------------------------------------------------------

The script works fine and makes the $filename.txt on the server with the exact text. Say I put:

--------------------------
testing
--------------------------

for the filename, then i put:

----------------------------------
testing...

testing....

testing.....
----------------------------------

Well it does exatly that in the text file which makes sense, but if say i

<?php include("hello.txt"); ?>

into another php file so that it will show the text in that text file on the page, since it oesn't have "<BR>" tages in it, it just shows up like this on the page:

-----------------------------------
testing... testing.... testing.....


------------------------------------

can someone please tell me how to avoid this so that when i include the text file into my php file that it doesn't do that, but instead is viewed with the returns. I know "why" this happens so u dont have to tell me, but please tell me a way around it.

Thank you,

FinalAeon :oops:

Posted: Thu Sep 18, 2003 6:37 pm
by JAM
You can use nl2br() for this.

Posted: Thu Sep 18, 2003 8:16 pm
by FinalAeon
Umm, i don't understand the instructions on how to use this. I used the html <pre></pre> tags which worked, but when i put in quotation or quote marks in the text field, when saved to the txt file it was like this:

------Typed In:------------------------------------

"He doesn't have a book."

------And was displayed like this:----------------

\"He doesn''t have a book.\"

------------------------------------------------------

See how the quotation and quote marks have backslashes? i need to get rid of those. If you can help me it would be very much appreciated.

Thank you,

FinalAeon

Posted: Fri Sep 19, 2003 4:08 am
by twigletmac
To get rid of the backslashes use stripslashes(). nl2br() lets you see the linebreaks without have to put the text into <pre> tags which can cause problems with word wrapping.

Mac

Posted: Fri Sep 19, 2003 2:01 pm
by FinalAeon
Can you please tell me how to apply these functions into my code? I am new at php and do not know how to apply it to my code. It would be very much appreciated.

Code is something like this:

---------------------------------------

fwrite($fw, $reviewcontent);

---------------------------------------

where the data of the text box in in $reviewcontent. if they insert quotes in the text box what would i do?

Posted: Fri Sep 19, 2003 2:25 pm
by m3rajk
can you show us the code... in

Code: Select all

tags

Posted: Fri Sep 19, 2003 2:31 pm
by jason
FinalAeon: What don't you understand about the manual page and the example that Twig suggested you look at?

Posted: Fri Sep 19, 2003 3:31 pm
by FinalAeon
no problem, here's the code...

---------------------------------------------------------------------------

$fw = fopen("/home2/fearmysk/public_html/Reviews/User Reviews/Reviews/$reviewtitle.txt","w+");

fwrite($fw,$reviewcontent);

fclose($fw);

---------------------------------------------------------------------------

i need to know how to use them in this situation (the function things). The $reviewcontent is the user input from a form message box. and if they put quotes or quotation marks they appear with backslashes in the $reviewcontent.

Thank you,

FinalAeon :oops:

Posted: Fri Sep 19, 2003 4:03 pm
by FinalAeon
alright i figured it out on my own, thanx for all the help yall! you can close the topic now.