July 19, 2011

how to submit a form from a php script

Question by elduderino

Possible Duplicate:
Auto Submitting a form (cURL)

I have a form which submits to a php script. In this form I need to collect all the $_POST data and then post this on to another form (the reason for this isn’t really relevant but there is a good reason).

My question is once I’ve collected all the data from the initial form submit, sanitised it and assigned it all to variables how do i then package it all up to send to the next form? The second form is expecting a $_POST with hidden fields with particular name attributes….so how do i do this? do I build the actual html and submit that somehow to the second form or do I buld some sort of array and send that?

hope this makes sense. Kind of hard to put in to words.

Answer by RiaD

  1. You can generate form and submit onLoad by Javascript
  2. You can use curl to send POST query (from your server but not from client)

Answer by Starx

The better way woudl be to store the sanitized variables in the session.

Collect all the information you need from all the forms you need.

Then after you have all the data needed, then finally update the DB (or Somethign else)

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!