text box

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
FinalAeon
Forum Newbie
Posts: 17
Joined: Sat Aug 02, 2003 2:51 pm
Location: ATL, GA

text box

Post 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:
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

You can use nl2br() for this.
FinalAeon
Forum Newbie
Posts: 17
Joined: Sat Aug 02, 2003 2:51 pm
Location: ATL, GA

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
FinalAeon
Forum Newbie
Posts: 17
Joined: Sat Aug 02, 2003 2:51 pm
Location: ATL, GA

Post 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?
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

can you show us the code... in

Code: Select all

tags
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

FinalAeon: What don't you understand about the manual page and the example that Twig suggested you look at?
FinalAeon
Forum Newbie
Posts: 17
Joined: Sat Aug 02, 2003 2:51 pm
Location: ATL, GA

Post 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:
FinalAeon
Forum Newbie
Posts: 17
Joined: Sat Aug 02, 2003 2:51 pm
Location: ATL, GA

Post by FinalAeon »

alright i figured it out on my own, thanx for all the help yall! you can close the topic now.
Post Reply