SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot Junk's Avatar
    Join Date
    Dec 2004
    Location
    Asia
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Passing parameters from one page to the other

    Hi,

    I need to pass parameters from one page to the other. The code below is not working. Please advise.


    PageA.php:

    <input type=button value="Proceed to reviewing stage" onClick="window.opener.location.href='PageB.php?ref_no=<?php echo $ref_no ;?>&stage=new_to_reviewing';">


    PageB.php:


    <?php if ($_GET['stage'] == new_to_reviewing) {

    $ref_num = $_GET['ref_no'];

    mysql_query ("UPDATE PROCESS_MANUSCRIPT_TABLE SET status = 'previewing' WHERE ref_no = $ref_num");
    }
    ?>


    I suspect this condition if ($_GET['stage'] == new_to_reviewing) has an error, since there is no update in the db.

    In another case,

    PageC.php

    <input type="hidden" name="stage" value="assign_admin" />

    PageD.php

    <?php if ($_POST['stage'] == 'assign_admin') {

    $id = $_POST['id'];
    $initial = $_POST['select_admin'];

    mysql_query ("UPDATE NEW_MANUSCRIPT_TABLE SET control = $initial WHERE id = $id");
    }
    ?>

    Similar problem, different methods of passing parameters.

    Please advise. Thanks
    Regards,
    Junk

    I am never more keen to learn...

  2. #2
    SitePoint Zealot Junk's Avatar
    Join Date
    Dec 2004
    Location
    Asia
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the correct code for the second case.

    PageC.php

    <input type="hidden" name="stage" value="assign_admin"></input>

    PageD.php

    <?php if ($_POST['stage'] == 'assign_admin') {

    $id = $_POST['id'];
    $initial = $_POST['select_admin'];

    mysql_query ("UPDATE NEW_MANUSCRIPT_TABLE SET control = '$initial' WHERE id = $id");
    }


    ?>
    Regards,
    Junk

    I am never more keen to learn...

  3. #3
    SitePoint Enthusiast nick b's Avatar
    Join Date
    Jan 2005
    Location
    Austin, TX
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the way I've always done it and it seems to work:

    Page A:

    HTML Code:
    <form action="PageB.php" method="post" />
    
    <input type="hidden" name="ref_no" value="<?=$ref_no?>" />
    
    <input type="submit" value="submit" />
    
    </form>
    Page B:

    PHP Code:

    $ref_no 
    $_POST['ref_no']; 
    Then you can use the "$ref_no" variable any way you want. Sounds like your problem might slightly more complicated than this, however.
    Nick Bartkowiak
    SerenityDigital.com

  4. #4
    SitePoint Zealot Junk's Avatar
    Join Date
    Dec 2004
    Location
    Asia
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    for pageA, I need the parameters to be passed by clicking a button and there is no form. I need to pass stage = new_to_reviewing to pageB.php

    PageA.php:

    <input type=button value="Proceed to reviewing stage" onClick="window.opener.location.href='PageB.php?ref_no=<?php echo $ref_no ;?>&stage=new_to_reviewing';">

    and PageB.php shall get the parameter stage, identify stage=new_to_reviewing and then execute the remaining codes.


    <?php if ($_GET['stage'] == new_to_reviewing) {

    $ref_num = $_GET['ref_no'];

    mysql_query ("UPDATE PROCESS_MANUSCRIPT_TABLE SET status = 'previewing' WHERE ref_no = $ref_num");
    }
    ?>

    However, I think there is something wrong with the syntax since the code is not working as intended.

    Thanks for yoru advise.
    Regards,
    Junk

    I am never more keen to learn...

  5. #5
    SitePoint Zealot Junk's Avatar
    Join Date
    Dec 2004
    Location
    Asia
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it.

    FYI, This is the right syntax:

    PageA.php:

    <input type=button value="Proceed to reviewing stage" onClick="window.opener.location.href='PageB.php?ref_no=<?php echo $ref_num ;?>&stage=new_to_reviewing';">


    PageB.php

    <?php if ($_GET['stage'] == new_to_reviewing) ?>
    Regards,
    Junk

    I am never more keen to learn...

  6. #6
    SitePoint Enthusiast nick b's Avatar
    Join Date
    Jan 2005
    Location
    Austin, TX
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I understand what you meant now. Cool.
    Nick Bartkowiak
    SerenityDigital.com

  7. #7
    SitePoint Zealot Junk's Avatar
    Join Date
    Dec 2004
    Location
    Asia
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks nick b. Enjoy your day!
    Regards,
    Junk

    I am never more keen to learn...


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
  •