Posted By

aloncarmel on 02/25/11


Tagged

postformjavascripthack


Versions (?)

Redirect post Data forward from code


 / Published in: PHP
 

URL: http://www.devunity.com

  1. /**
  2. *
  3. * Creates a form and posts all the data using javascript recieved to the url provided
  4. * @param string $url
  5. * @param string $postarray //Multi level array, array( array('fieldname','fieldvalue') )
  6. */
  7. public function PostForward($url,$postarray=null)
  8. {
  9.  
  10. $string = '<form method="post" name="form" action="'.$url.'">';
  11.  
  12. if ($postarray != null) {
  13.  
  14. foreach ($postarray as $postfield) {
  15. $string .= '<input type="text" name="'.$postfield[0].'" value="'.$postfield[1].'">';
  16.  
  17. }
  18.  
  19. }
  20.  
  21. $string .= '</form>';
  22. $string .= '<script> document.form.submit();</script>';
  23.  
  24. echo $string;
  25.  
  26. }

Report this snippet  

You need to login to post a comment.