Results 1 to 2 of 2

Thread: an Idea possible

  1. #1
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default an Idea possible

    This is an idea i had to make 3 page instead of 20. There are going to be 12 of these forms on this page. I'm going to use a toggle to show the files the user can edit. The submit will only submit the form it is in correct? And will the input type="hidden" name="page" value="alumni" pass over and open the text file associated with it in the submitpage.php.
    This is the code for the first page where there will be a list of files:
    PHP Code:
    <form method="post" action="submitpage.php" style="border:#000000 2px solid; width:750px;">
    <input type="hidden" name="page" value="alumni" />
    <textarea name="data" rows="20" cols="90">
    <?php
    $myFile 
    "alumni.txt";
    $fh fopen($myFile'r');
    $theData fread($fh20000000);
    fclose($fh);
    echo 
    $theData;
    ?>
    </textarea>
    <input type="submit" value="Submit Changes" style="text-align:center; font-family:Geneva, Arial, Helvetica, sans-serif; font-size:14px;" />
    </form>
    This is the submitpage.php
    PHP Code:
    <?php
    $notes 
    $_POST['data'];
    $page $_POST['page'];
    $File =  ($page ".txt");
    $Handle fopen($File'w');
    $Data =   $notes;
    fwrite($Handle$Data);
    fclose($Handle);
    echo 
    "The" $page "page has been updated.";
    ?>
    Thanks for any suggestions or answers you can offer.

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    You might be interested in file_get_contents and file_put_contents.

    Yes, a submit button will only submit its own form, and the hidden field will work as you intend. But why are you using 12 forms? Why not use a select box full of the 12 possible file names?
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

Bookmarks

Posting Permissions

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