Thread: Web form updates a txt file
-
June 7th, 2003, 10:17 AM #41
So I've got to change this
into something like thisCode:<TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="whatitis" cols="100" rows="5" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/whatitis.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR>
this is getting confusing...lol, Of course, its me that's making it confusing. Look at my "Post.php" which I call ourhome.phpCode:<? $display = file("../txtfiles/ourhome/whatitis.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="whatitis" cols="100" rows="5" wrap><?php echo $displaytext; ?></textarea> </p><br></TD> </TR>
Code:<HTML> <HEAD> <TITLE></TITLE> </HEAD> <body> <form action="ourhome2.php" method="post"> <CENTER> <P ALIGN=CENTER> <TABLE WIDTH="600" bordercolor="black" CELLPADDING="0" CELLSPACING="0" BORDER="0"> <TR> <TD WIDTH="100%" VALIGN=TOP><p>This is where you can edit the contents of the "Our Home" web page. There are also a few more blank areas where more information could be added.</p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center>Whatitis: A short sentence that explains what's below.</TD> </TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="whatitis" cols="100" rows="5" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/whatitis.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="title" cols="100" rows="5" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/title.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="intro" cols="100" rows="15" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/intro.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="firstheader" cols="100" rows="5" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/firstheader.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="firstbody" cols="100" rows="15" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/firstbody.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="secondheader" cols="100" rows="5" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/secondheader.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="secondbody" cols="100" rows="15" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/secondbody.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="thirdheader" cols="100" rows="5" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/thirdheader.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="thirdbody" cols="100" rows="15" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/thirdbody.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="fourthheader" cols="100" rows="5" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/fourthheader.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="fourthbody" cols="100" rows="15" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/fourthbody.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="fifthheader" cols="100" rows="5" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/fifthheader.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p><br></TD> </TR> <TR> <TD style="border-bottom-style: solid; border-bottom-width:1" style="border-right-style: solid; border-right-width: 1" style="border-top-style: solid; border-top-width:1" style="border-left-style: solid; border-left-width: 1" WIDTH="100%" BGCOLOR="#F1F1F1" VALIGN=center> </TD> </TR> <TR> <TR> <TD WIDTH="100%" VALIGN=TOP><p> <textarea name="fifthbody" cols="100" rows="15" wrap> <?php //this is the text file to write to, they can't contain numbers, ie 1header.txt does not work $display = file("../txtfiles/ourhome/fifthbody.txt"); $displaytext = implode("", $display); $displaytext = stripslashes($displaytext); echo $displaytext; ?> </textarea> </p></TD> </TR> </TABLE> <p> <input type="submit" name="Submit" value="Submit Changes to OurHome"> </p> </form> </body></html>
-
June 7th, 2003, 10:24 AM #42
oh wait, i think i might have it....i list the variables at the top like so?
then in the respectable text areas I putCode:$display1 = file("../txtfiles/ourhome/whatitis.txt"); $displaytext1 = implode("", $display1); $displaytext1 = stripslashes($displaytext1); $display2 = file("../txtfiles/ourhome/title.txt"); $displaytext2 = implode("", $display2); $displaytext2 = stripslashes($displaytext2); $display3 = file("../txtfiles/ourhome/intro.txt"); $displaytext3 = implode("", $display3); $displaytext3 = stripslashes($displaytext3); $display4 = file("../txtfiles/ourhome/firstheader.txt"); $displaytext4 = implode("", $display4); $displaytext4 = stripslashes($displaytext4); $display5 = file("../txtfiles/ourhome/firstbody.txt"); $displaytext5 = implode("", $display5); $displaytext5 = stripslashes($displaytext5); $display6 = file("../txtfiles/ourhome/secondheader.txt"); $displaytext6 = implode("", $display6); $displaytext6 = stripslashes($displaytext6); $display7 = file("../txtfiles/ourhome/secondbody.txt"); $displaytext7 = implode("", $display7); $displaytext7 = stripslashes($displaytext7); $display8 = file("../txtfiles/ourhome/thirdheader.txt"); $displaytext8 = implode("", $display8); $displaytext8 = stripslashes($displaytext8); $display9 = file("../txtfiles/ourhome/thirdbody.txt"); $displaytext9 = implode("", $display9); $displaytext9 = stripslashes($displaytext9); $display10 = file("../txtfiles/ourhome/fourthheader.txt"); $displaytext10 = implode("", $display10); $displaytext10 = stripslashes($displaytext10); $display11 = file("../txtfiles/ourhome/fourthbody.txt"); $displaytext11 = implode("", $display11); $displaytext11 = stripslashes($displaytext11); $display12 = file("../txtfiles/ourhome/fifthheader.txt"); $displaytext12 = implode("", $display12); $displaytext12 = stripslashes($displaytext12); $display13 = file("../txtfiles/ourhome/fifthbody.txt"); $displaytext13 = implode("", $display13); $displaytext13 = stripslashes($displaytext13); <form action="ourhome2.php" method="post">
and displaytext2, and so forth, right?Code:<?php echo $displaytext1; ?>
-
June 7th, 2003, 10:29 AM #43
yeh that it remeber to put <? at the begining and ?> at teh end of delcaring them varibles to tell the server or browser that it php code other wize it will diplay as plain text
so now inside the form we have a text box it will look like this
also if you are worried about showing the <br> in the text box when it loads the file have a look how to hide themCode:<textarea name="name" cols="100" rows="15"><?php echo $displaytext1; ?></textarea>
http://jub.jkub.com/test2.php
-
June 7th, 2003, 10:34 AM #44
YEAH!!! sweet, it works....i figured out the <? ?> thing by looking at the post2.php. awesome.
any idea where i can go to figure out that <br> thing? I'm doing this for a web page, and the text all runs together.
http://dky.sytes.net/rwb/
-
June 7th, 2003, 10:43 AM #45
humm do you want a <br> at the end of the text you right or after so many characters. if it is after so many characters why not put in a frame on the main page then <? include("your textfile"); ?>
this will automatcially wrap the words so it wont be i continuois line.
if you want to put a br at the end of the block of text you wrote then read back i explaned how to do it.
-
June 7th, 2003, 10:45 AM #46Originally posted by Carl-cox-
1. this requres modification to the above script a little bit hope you can understand this
as you can see $news is the varible from the textbox and $filename if the varible for the filenameCode:$stripped = stripslashes($news); $somecontent = "$stripped <br>; if (is_writable($filename)) { if (!$handle = fopen($filename, 'w')) { print "Cannot open file ($filename)"; exit; } if (!fwrite($handle, stripslashes($somecontent))) { print "Cannot write to file ($filename)"; exit; } print "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { print "The file $filename is not writable"; }
Last edited by Carl-cox-; June 7th, 2003 at 10:47 AM.
-
June 7th, 2003, 11:05 AM #47
when I type text in the text area, and then hit the carriage return, it doesnt put a <br> in the txt file, thus causing the text to all run together when called up on the php main page. Is there a way around that? Maybe its not supposed to put a <br>, but someway to recognize the carriage return.?.?.?
-
June 7th, 2003, 11:17 AM #48
umm i really dont know on this one, there is a way as this forum uses but i dont know how it works all i can think is it counts the number of lines then puts a <br> at the end there for a blank would be <br> on it own making a line. but i dont know how to count lines in a text file then to even put <br> at the end
-
June 7th, 2003, 12:42 PM #49
i dont know what you mean about counting lines? I just want it to <br> when I type in the textarea and hit the "enter" key
BTW, do you have an instant messenger?
-
June 9th, 2003, 09:48 AM #50
nl2br() took away the br's in case anyone wants to know.
Does anyone know of a php function that keeps spaces? as for right now, I'll type something like "1. hello world" and it comes up on my page like "1. hello world".
-
June 10th, 2003, 07:06 AM #51
look what i found and thought of you

http://phpfreaks.com/forums/viewtopi...74074d641a77ae
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)



LinkBack URL
About LinkBacks






Reply With Quote

Knew it had to be you at this hour. Knew before I looked. 'Course, it could have been Paul, or Whir....:lol:
Is It Just Me? v233893843