Results 1 to 21 of 21
  1. #1

    Help with simple form to page script...

    Hi,

    I need a little help here with something that I know should be fairly easy.

    I have a guy writing an article for my site...instead of me downloading, formatting, coding, copying and pasting every week to update the article...I want to create a form that will have different text areas (about 10) which he can fill in the differetn sections of his article in all the text areas, hits submit, and the entered info is written to a php file...that's easy enough except...how do I get it to stay there? Like I want it so once he submits his article and it writes to the file...everyone can see it and it will stay there UNTIL he writes a new article...and hits submit, then the new info will overwrite the last article.

    Anyone have an easy way to do this???

  2. #2
    Join Date
    Dec 2001
    Location
    New Hampshire
    Posts
    93
    <form action="<?=$PHP_SELF?>"><textarea name="stufftosubmit" rows="7" cols="77"></textarea><input type="submit" name="submit"></form><a href="page.html">page.html</a>

    <?
    if($submit){$updatedpage=fopen('page.html','w');
    fputs($updatedpage, stripslashes($stufftosubmit));
    fclose($updatedpage);
    }?>

    [EDIT]wrong attributes; this is a textarea, not an image [/EDIT]
    [EDITAGAIN]added stripslashes(), otherwise y'get those nasty \s all over the place with quotes [/EDITAGAIN]
    Last edited by prosayist; 09-14-2002 at 04:54 AM.
    WYSIWYG

  3. #3
    could you be more specific as to what to do with that?

    thanx
    Lime Drop Marketing!
    Web Design | Graphic Design | Logo Design
    http://www.limedrop.ca

  4. #4
    Join Date
    Dec 2001
    Location
    New Hampshire
    Posts
    93
    yeah;
    -make a page called (for example) "formpage.php"
    -put all that code in it
    -repeat "about 10" times
    -load it to your server/browser
    -type something in the textarea
    -submit
    -click the link to 'page.html'
    it's very simple and prob'ly you'll wanna make it better but I think it'll get you goin'
    anything else?
    WYSIWYG

  5. #5

    okay so...

    I put that code into the text area's page...there will be multiple textareas does that change anything?

    Then it writes to page.html or page.txt, whatever...

    Then to I want to have a <?php require ("page.txt"); ?> in the page that I want the article to appear? Is that how this will work in full?

  6. #6

    Thanx but..

    okay that works...but one question...the stuff he submits...I want html tags around the stuff he submits...and also some text he won't be submitting like headings.

    For example:

    OFFENSE:
    Quarterbacks: The Riders have great depth, yada yada yada.
    EDGE: Riders

    K so in that example...he will be submitting the "The Riders have great..." paragraph. I want it to that it also writes the offense and quarterbacks lines...and the Edge line (he will submit 'Riders' in a text box)...and I also want to have it so when he submits it...his submission will have <p> tags (paragraph tags in case it accepted the html and u can't read the tag) around it.

    How do I accomplish this?

  7. #7
    Oh and this might be too much work...but is there any way to archive the current article before its written over? Possibly have it so that when he enters a new article, it will rename the current one, and then use the original name for the updated one?
    Lime Drop Marketing!
    Web Design | Graphic Design | Logo Design
    http://www.limedrop.ca

  8. #8
    Join Date
    Dec 2001
    Location
    New Hampshire
    Posts
    93
    YEAH, of COURSE there's a way! (with PHP, there's always a way)
    I'm not gonna write the whole script for ya 'cause, as you said, it's simple..
    All ya' gotta do is add <input type="text" name="OFFENSE" (or whatever your variable name is) and make a new variable so
    PHP Code:
    $formattedOFFENSE=<h3>$OFFENSE</h3>;
    /*same for your other things you want formatted, then, using the same syntax as before*/
    fopen('page.txt','w');
    print 
    '$formattedOFFENSE' 
    it's a quite a bit more complicated than what I've explained but quite a bit easier than what you'd expect..
    just do a little research, check out the manual at php.net, look on PHP Builder, do a google search; somebody's prob'ly already got something written for what you're tryinna do
    Last edited by prosayist; 09-14-2002 at 05:28 AM.
    WYSIWYG

  9. #9
    actually don't worry about the file renaming archive thing...I can do that a different way...no worries.
    Lime Drop Marketing!
    Web Design | Graphic Design | Logo Design
    http://www.limedrop.ca

  10. #10
    Join Date
    Dec 2001
    Location
    New Hampshire
    Posts
    93
    like this (for example).. add other <input name="?"> for your other variables;
    PHP Code:
    <form action="<?=$PHPSELF?>">
    <h3>HEADER:
    <br>
    <input type="text" name="header"></h3>
    <p>CONTENT:
    <br>
    <textarea name="stufftosubmit" rows="7" cols="77">
    </textarea>
    <input type="submit" name="submit">
    </p>
    </form>
    <a href="page.html">page.html</a>

    <?
    if($submit){
    $updatedpage=fopen('page.html','w');
    $header='<h3>'.$header.'</h3>';
    $content=stripslashes($stufftosubmit);
    fputs($updatedpage,($header.'<br><p>'.$content.'</p>'));
    fclose($updatedpage); 
    }
    ?>
    WYSIWYG

  11. #11
    Okay thats cool...

    sorry to keep bugging ya...

    But I tried putting styles sheets on the page I have that calls the page.txt and now nothing comes up at all...?
    Lime Drop Marketing!
    Web Design | Graphic Design | Logo Design
    http://www.limedrop.ca

  12. #12
    but hey don't worry about that...cuz I'm an idiot and firgure it out as soon as I posted that...

    hehe...

    Thanx a ton for your help anyways!!!
    Lime Drop Marketing!
    Web Design | Graphic Design | Logo Design
    http://www.limedrop.ca

  13. #13
    Join Date
    Dec 2001
    Location
    New Hampshire
    Posts
    93
    hey, Welx a ton back at ya
    WYSIWYG

  14. #14
    hope you see this...

    actually that worked...but...

    I must have too much information to submit because when i fill out all my form fields with about as much info as would be entered normally...it won't work...it justs clicks and nothing happens. If I only put a couple things in...it works perfect.

    This is no doubt due to the query string right?

    I mean when you submit...there is a huge query string of EVERYTHING that was submitted right in the address bar...likely with the amount of info I am putting in...it's too much?

    Anyways...do you know how to fix this?

    Currently the script is sitting at http://www.riderfans.com/myphp/myphp.php
    Lime Drop Marketing!
    Web Design | Graphic Design | Logo Design
    http://www.limedrop.ca

  15. #15
    Join Date
    Dec 2001
    Location
    New Hampshire
    Posts
    93
    try adding this;
    "<form method="post">"
    (if you're not using the 'action' attribute, you don't even need to put it there)
    WYSIWYG

  16. #16
    Can I buy you a beer?

    Thanx a lot man!

  17. #17
    Join Date
    Dec 2001
    Location
    New Hampshire
    Posts
    93
    Heineken, please
    .. and thank yoU (gladta help)
    WYSIWYG

  18. #18
    sorry to keep bugging you but I need one more favour...

    Okay so I have the while form set up...it works great...writes to the file...my other file calls it...works great...

    But I also want it so that one of my other pages displays just ONE of the entries from the forms...

    For example...

    I have text areas of:
    'intro', 'quarterback', 'receivers'

    When those are filled in and submitted...they are written to page.txt...

    I them have a file mits.php call page.txt and displays all the info...

    Now I want a file called index.php to display ONLY the 'intro' submission...

    I tried to do this by on the article submission page, write just the intro part to another file called intro.txt...and have index.php call intro.txt however...I can't get it to write to intro.txt...it stays blank...

    how can I accomplish this? Thanx.

    (the way I tried was just to copy the open page.txt codes and use it in the same function...?)
    Lime Drop Marketing!
    Web Design | Graphic Design | Logo Design
    http://www.limedrop.ca

  19. #19
    Join Date
    Dec 2001
    Location
    New Hampshire
    Posts
    93
    PHP Code:
    <form action="<?=$PHPSELF?>">
    <textarea name="introtext"></textarea>
    <br>
    <h3>HEADER:
    <br>
    <input type="text" name="header"></h3>
    <p>CONTENT:
    <br>
    <textarea name="stufftosubmit" rows="7" cols="77">
    </textarea>
    <input type="submit" name="submit">
    </p>
    </form>
    <a href="page.html">page.html</a>

    <?
    if($submit){
    $updatedpage=fopen('page.html','w');
    $header='<h3>'.$header.'</h3>';
    $content=stripslashes($stufftosubmit);
    fputs($updatedpage,($header.'<br><p>'.$content.'</p>'));
    fclose($updatedpage);
    $intro=fopen('intro.txt','w');
    fputs($intro,$introtext);
    fclose($intro);
    }
    ?>
    WYSIWYG

  20. #20
    yeah I got everything working great now...thank you so much!
    Lime Drop Marketing!
    Web Design | Graphic Design | Logo Design
    http://www.limedrop.ca

  21. #21
    Join Date
    Dec 2001
    Location
    New Hampshire
    Posts
    93
    so how'bout that Heineken?
    WYSIWYG

  22. Newsletters

    Subscribe Now & Get The WHT Quick Start Guide!

Related Posts from theWHIR.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •