PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello. I am trying to get data in a PHP readable format from http://noosphere.princeton.edu/data/basket_csv.html
Here is a snippet of the source code for that form:
[syntax="html"]<form method=get name="request" action="/cgi-bin/eggdatareq.pl">
<input type=hidden name=z value="1">
<center>
<table border cellpadding=5>
<tr>
<th>
Date:
<td>
<input type="text" name="year" value="1998" size="5">
<select name=month size=1>
<option value=1> January
<option value=2>February
<option value=3>March
<option value=4>April
<option value=5>May
<option value=6>June
<option value=7>July
<option value=8>August
<option value=9>September
<option value=10>October
<option value=11>November
<option value=12>December
</select>
<input type="text" name="day" value="1" size="3">
Basically, I want to have PHP send a request to http://noosphere.princeton.edu/cgi-bin/eggdatareq.pl with "year" set to the current year, "date" sent to the current date, etc, just as if a user submitted the form. Doing so should return a CSV file, which I can then process with getcsv().
How can I use PHP to submit a request with the necessary variables to get a .csv file back?
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hmm, well is there a way that I could use Perl to access and process the data, then save it into a MySQL that I could then access with PHP? I want to use the data from this as part of a php script that is already written, so I need to be able to somehow integrate it with PHP.
Also, I've never worked with Perl. Is there a simple way to get and a process a csv file from that form? If not, can you refer me to tutorial where I can learn how to do that sort of thing.
I don't know perl very well either -- you would have to go into the perl script and either have it redirect to the PHP script or print a link to the PHP script.
Here's a thought--could I make a PHP page that would use headers to submit a form to the perl file with the necessary variables, and then somehow grab the csv file that the perl file generates?
Cause when you fill out the form @ http://noosphere.princeton.edu/data/extract.html, it just takes you to an HTML page with all the data on it. So if I made my own form that sent the variables, could I somehow use PHP to grab the resultant HTML file?
You could submit to the PHP script, and use include("http://noosphere.princeton.edu/cgi-bin/eggdatareq.pl") in the PHP script to execute the perl script. You must use the URL in the include call, not the path name.
edit: you would also have to pass the form data from the php script to the perl script somehow. might be better to have the perl script redirect to the php script after it's done.
The problem though is that I can't edit the Perl script--the GCP told me I could use their data, but they didn't give me access to their server. Maybe I could make my own Perl script on my server that would send data to their script, get the resultant csv file, and then stick the data into MySQL...
Tom
Is the perl script returning a csv file? Are you able to pass information to that script (like the date)? If so, how does the perl script accept that information.
Alright, now that I understand your original question (I'm apparently slow), just copy that form from the site onto your page. Have the form submit to your php script. In that script, construct the url that you want to pass to the perl script (e.g., http://noosphere.princeton.edu/cgi-bin/ ... year=$_GET['year']&month=$_GET['month']......). Use file_get_contents with the constructed url as the argument, and you should have the output of the perl script in a string.