Jump to content

[SOLVED] Forward POST-variables


lindm

Recommended Posts

I have a form which should be submitted with either of two actions. Tried with javascript but this seems unreliable. Now looking at php and a processor page as the action of the form (process.php) which then sends the user to the different actionpages...can't figure out how to forward the post-variables to the different pages...

 

Example process.php

<?php
  if(array_key_exists('goto1', $_REQUEST))
  {
   CODE FOR GOTO goto1.php
  }
  else if(array_key_exists('goto2', $_REQUEST))
  {
CODE FOR goto2.php  
}

?>

 

 

Link to comment
Share on other sites

So on the top of your processing page, do print_r($_POST); and click on one of the buttons. See what it says. Then go back and click on the other, and see what it says now.

 

Also, make sure they have values as well. value="action1" and value="action2"

Link to comment
Share on other sites

Well it shows

 

[goto1] => Value1

 

So ID/NAME => Buttonvalue

 

Would the code be more like

<?php
  if($_POST[goto1]=Value1)
  {
  CODE TO POST $_POST to goto1.php
  }
  else if($_POST[goto2]=Value2))
  {
  CODE TO POST $_POST to goto2.php
}

?>

 

 

Link to comment
Share on other sites

Well it shows

 

[goto1] => Value1

 

So ID/NAME => Buttonvalue

 

Would the code be more like

<?php
  if($_POST[goto1]=Value1)
  {
  CODE TO POST $_POST to goto1.php
  }
  else if($_POST[goto2]=Value2))
  {
  CODE TO POST $_POST to goto2.php
}

?>

You could use redirects to "goto1.php" and "goto2.php", but I think a better solution would be to simply implement all the functionality you're looking for in one page.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.