Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Feb 2006
    Posts
    262
    Thanks
    23
    Thanked 1 Time in 1 Post

    Post Hard to say in one line !!

    Good day to you all,
    I'm in a situation where I have 12 pages (month page)
    where the user can add to the page on demand.

    This is very simple, no problem to do, but I need more then that.

    There is 3 way of adding to the file, 3 different template.
    - with image
    - Without image
    - With a country flag, as image


    Each template is in 2 step :
    - Form
    - action-page.php


    My problem is that depending on which month the user wants to add to, the "action-page.php" should add to this one.

    I mean the fopen within the "action-page.php" should have the month page to open and add to.

    Can someone please point me or help me with this !

    If you need more info or see my code let me know !
    Thanks!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,549
    Thanks
    8
    Thanked 1,095 Times in 1,086 Posts
    Your form will be something like this:

    <form action="action-page.php" method="post">
    <select name="month">
    <option value="January">January</option>
    <option value="February">February</option>
    <option value="March">March</option>
    </select>
    <input type="submit" name="submit" value="submit">
    </form>


    Your PHP script will start out like this :

    PHP Code:
    <?php
    // read the month value from the form
    $month=$_POST['month'];

    //now that you have the month, you can build a
    //variable to define the directory or file.
    //you didn't specify how you are naming your files,
    //buy I assume the month is part of the filename:

    $filename=$month."_file.txt";

    //open it and do what you want with it.
    ?>
    Other than that ... not enough information to provide anything else.

  • #3
    Regular Coder
    Join Date
    Feb 2006
    Posts
    262
    Thanks
    23
    Thanked 1 Time in 1 Post
    I need to pass the value posted on a 3rd page, that's my problem.

    My files are named by months yes, but they are numbered, which is not a problem here.

    But that code would work if it would a been posted on a 3rd page where I can save it, cause my editor is another file I have another file that save to file.

    You just need to ask what you want to know, you never loose to ask...

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,549
    Thanks
    8
    Thanked 1,095 Times in 1,086 Posts
    If you're entering the 3rd page from a form,
    use a hidden value on the form that you then
    read on the 3rd page.

    You can pass a variable from a form, or from a URL.
    You can read the variable with:
    $_GET['variable'];
    or
    $_POST['variable'];
    It all depends on how you are transferring it ...

    We don't know how you are getting from page 2 to page 3.

    "You just need to know what you're asking for, you lose by not asking ..."

  • #5
    Regular Coder
    Join Date
    Feb 2006
    Posts
    262
    Thanks
    23
    Thanked 1 Time in 1 Post
    yes from a form.

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,549
    Thanks
    8
    Thanked 1,095 Times in 1,086 Posts
    On the 2nd page, use <input type="hidden" name="var1" ... > and populate
    that form with the variables you need to pass onto the 3rd page.

    On the 3rd page, grab those hidden variables along with the other ones.

    $var1='$_POST['var1'];
    (or whatever you call your hidden variables).


  •  

    Posting Permissions

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