Redirect post Data forward from code


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

URL: http://www.devunity.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.