Pass value to header?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Garry Jones

    Pass value to header?

    When processing a form I am reading in a value to a mysql database. I then
    redirect the user to a "thank you" page with Header. What I would like is to
    remind the user the value he/she keyed in. Can I pass the variable in the
    Header command?

    What I want to do in the following is echo the value of $inx01 in
    thankyou.php?

    <?php
    mysql_connect(" Codes Removed ") or die(mysql_error ());
    mysql_select_db (" Database Name removed ") or die(mysql_error ());

    $inx01=$_POST['fardvagonf'];

    mysql_query("IN SERT INTO table1 VALUES ('$inx01')");
    echo mysql_error();

    mysql_close();

    Header("Locatio n: http://www.mydomain.co m/thankyou.php");
    exit;

    ?>

    Garry Jones
    Sweden


  • Ken Robinson

    #2
    Re: Pass value to header?

    Garry Jones wrote:[color=blue]
    > When processing a form I am reading in a value to a mysql database. I then
    > redirect the user to a "thank you" page with Header. What I would like is to
    > remind the user the value he/she keyed in. Can I pass the variable in the
    > Header command?[/color]

    [snip]
    [color=blue]
    > Header("Locatio n: http://www.mydomain.co m/thankyou.php");
    > exit;
    >[/color]

    There are two different methods you can use:
    1) Put the value into a session variable. Before the 'header()"
    function, put

    $_SESSION['inx01'] = $inx01;

    Then in the thankyou.php script, you can get the value by referencing
    $_SESSION['inx01']

    Be sure you put

    session_start() ;

    at the start of each script.

    2) Pass the value on the URL:

    header('Locatio n: http://www.mydomain.co m/thankyou.php?in x01=' .
    $inx01);

    and the you can use the value in $_GET['inx01']

    Ken

    Comment

    Working...