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
https://forums.phpfreaks.com/topic/70014-solved-forward-post-variables/
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"

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
}

?>

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.