How to convert $_GET variable into $_POST variables

Discussion in 'Programming' started by ferdousx, Dec 5, 2008.

  1. #1
    Is there any way to convert $_GET variable into $_POST variables?

    for example if there is a page "page1.php?v=123", how can i pass the value of v to another page "page2.php" automatically ?

    One way to do this (I think) is via hidden form variable and submit by javascript by onload() method.

    Is there any other way?
     
    ferdousx, Dec 5, 2008 IP
  2. QiSoftware

    QiSoftware Well-Known Member

    Messages:
    805
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    158
    #2
    Do you wish to open the new [second] page? If so, use the JavaScript Open function triggered by the callback [onload()] to open the new page with the variable.

    It was not clear to me what the second page was doing so if you could explain maybe I can provide a clearer option.

    Q...
     
    QiSoftware, Dec 5, 2008 IP
  3. JREAM

    JREAM Member

    Messages:
    160
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #3
    Could this work?
    $_POST[($_GET[$page])];
     
    JREAM, Dec 7, 2008 IP
  4. Tarkan

    Tarkan Peon

    Messages:
    491
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Using CURL PHP Tutorial to send POST to another page is the easiest way, but you have to have CURL installed. It's not hard.
     
    Tarkan, Dec 7, 2008 IP
  5. SGBoise

    SGBoise Peon

    Messages:
    647
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    you could save the variables in a session. So in page2 you would just check to see if the session varibles exists and retrieve the values.
     
    SGBoise, Dec 7, 2008 IP
  6. ColorWP.com

    ColorWP.com Notable Member

    Messages:
    3,120
    Likes Received:
    100
    Best Answers:
    1
    Trophy Points:
    270
    #6
    In your case:

    <?php
    $get = $_GET['v']; // gets the value of the 'v' and assign it to $get
    header("location: page" . $get . ".php"); // redirects to page(value of $get).php
    die(); // ends the script in case something goes wrong and it can't redirect
    ?>
    PHP:
    I wrote this on-the-fly so it may not work and may need some small edits.
     
    ColorWP.com, Dec 8, 2008 IP
  7. bovcan

    bovcan Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    This will help me too, thx.
     
    bovcan, Dec 8, 2008 IP