Action and Header

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sheldonlg@gmail.com

    Action and Header

    I have used the action= statement to send the form to a new page which
    can get the posted variables.

    I have used the header("Locatio n: foo.php) statement after testing on
    the submit with isset.

    What I want to know is if they can be combined. That is, test first
    with the isset, and if no errors go to the action call. Simply going
    with the header call doesn't seem to send the form variables.

    Am I missing something?

    Shelly

  • C. Taddiken

    #2
    Re: Action and Header

    sheldonlg@gmail .com wrote:[color=blue]
    > I have used the action= statement to send the form to a new page which
    > can get the posted variables.
    >
    > I have used the header("Locatio n: foo.php) statement after testing on
    > the submit with isset.
    >
    > What I want to know is if they can be combined. That is, test first
    > with the isset, and if no errors go to the action call. Simply going
    > with the header call doesn't seem to send the form variables.
    >
    > Am I missing something?
    >
    > Shelly
    >[/color]

    Should be pretty easy - just try the following:

    header("Locatio n: foo.php?varname =varvalue&varna me2=varvalue2") ;

    This won't really work if you are passing sensitive information to the
    next page because it will be
    part of the URL - if you don't mind me asking why do you need to go to a
    different page to interpret
    and/or manipulate the data? You might want to think about keeping it a
    part of the page that is
    determining whether the variables are set. I would suggest something
    like the following:

    if( isset($varname) && isset($varname2 ) )
    {
    //your function here


    //after function is complete then forward to next page
    header("Locatio n: wherever.php");
    exit;
    }

    Just a thought.

    Comment

    • David Haynes

      #3
      Re: Action and Header

      sheldonlg@gmail .com wrote:[color=blue]
      > I have used the action= statement to send the form to a new page which
      > can get the posted variables.
      >
      > I have used the header("Locatio n: foo.php) statement after testing on
      > the submit with isset.
      >
      > What I want to know is if they can be combined. That is, test first
      > with the isset, and if no errors go to the action call. Simply going
      > with the header call doesn't seem to send the form variables.
      >
      > Am I missing something?
      >
      > Shelly
      >[/color]
      What I think you are asking is how to combine a POST method with a GET
      method in order to chain the processing of a form across multiple php
      files. That is: the action from the form (assuming the method is POST)
      will post the form variables to the first php file (named in the
      action). After you do the isset, you then want to pass control to the
      second php file for further processing.

      If so, there are a number of ways to accomplish this but the two
      simplest are:
      1. call the second php file using a GET method. That is: use the calling
      form of second.php?var1 =val1&var2=val2 ... As you can see, this will
      expose the values for var1, var2, etc.
      2. use the SESSION mechanism to pass the values to the second php file.
      This involves writing the values to the session and then using the
      header to call second.php. Second.php must use the session to read back
      the values it is expecting.

      Most other ways involve the use of temporary storage in a disk file,
      database table or shared memory segment. These are less efficient and
      more complex to set up.

      -david-

      Comment

      Working...