1

I have an HTML form that I need to submit to a php file that adds it to a database, as well as to an existing php file that adds it to an online CSV file.

Any ideas?

1
  • you cant, you have to submit to one file, and in that include the other files\code Commented Mar 10, 2011 at 20:07

3 Answers 3

4

Create a new php file, like this:

<?php

  include('form_handler_1.php');
  include('form_handler_2.php');

?>
Sign up to request clarification or add additional context in comments.

Comments

1

Use the $_POST or $_GET array to call the other file.

For example after your mysql take the $_POST and submit them with $_GET to the next file.

file 1:

$name = $_POST['name'];
$address = $_POST['address'];
## put here your mysql query and connect
## end query

##submit the values as variables to the other script

$url = "http://www.mysite.com/seconfile.php?name=".$name."&address=".$address;
file_get_contents ($url);

second file:

$name = $_GET['name'];

Curl would also fit or fopen or file.

You can do that endlessly and shorten the coding with using a foreach loop through the array creating the urls.

coded but not tested

2 Comments

Can I also use POST to send it to the second file?
POST requires curl instead of file_get_contents. secure the get params or use a strange filename than u should be save though :)
0

You could send it to your database php file, and then use curl to send the request to the second php file.

See this link for instructions on how to use curl :)

4 Comments

seems convoluted you should only use curl for external requests, not internal.
I also need to complete and submit an online form using php later on, think curl will come in handy..
@Dagon true, but couldn't think of another way really.
@Andre Make sure you mark the answer as answered to help out other people in the future :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.