Forum Moderators: coopster
This was dropped in my lap because I'm the most persistent when presented with a challenge. ;) I've been web surfing trying to find the answers to my questions for the last 14 hours or so -- I have a headache now.
Our customers have been entering initial order information without CC number in a form on our non-secure server. That data is forwarded via POST to the credit card processor's secure server where the customers enter the CC number and expiration date. Later we wre using a batch download from the secure server to retrieve the full billing information in a CSV file to import to our billing software for monthly re-billing.
As of the 16th we need to move our form to our secure server (for which we still need to purchase and install a certificate on Monday), have our form collect the CC number as well as the rest of the information, write the form data to a local CSV file in the format expected by our billing software, *AND* send the data via the POST method over a secure connection to the proccessor's secure server.
Most of us in the office can handle HTML pretty well. Writing a CGI script from scratch is beyond us.
Thank you for any help available, we are currently in "panic mode". :(
Gerald
<form action="page/on/my/site.php" method="post">
yada yada yada
</form>
Then on your php page save the customer data to the db, load the $_POST data back into hidden form fields and send it on.
If you are putting in 14 hour days, ten days is plenty of time to be up and running ;)
WBF
Not using MySQL. The billing program is a standalone app that was designed to work with the data files downloaded from Authorize.Net. I just need to write the data out to a CSV file in the same format that they were sending. We have example files to work with from previous downloads.
I have the php docs stored here locally plus a couple of good searchable tutorials. I should be able to cobble something together. I'll load the test forms on the apache-ssl server I have running at the house for remote testing.
I work 59.5 hours/week (usually). 1530 - 0000 Thursday then 0700 - 0000 Friday/Saturday/Sunday (yes, 17 hour days). And, since I live an hour away I usually just stay here at the office (all the amenities except a shower <sigh>) for the full 80 hours.
Gerald
Can I do TWO actions from an HTML form?
Not really. The way some thing like this is *normally* done is .. the form submits data to your secure server .. and your secure server in turn connects to the processor's server and posts data and gets response from there and shows it to the user.
However I do not see any thing technically wrong with a 2 step method willybfriendly has suggested. Should be easier if programming is the challenge.
How about the quick and dirty script example for writing to a file.
writing to a file is pretty simple. open it, write it, close it.
something like this would work.
$writetocsv = $_POST['field1'] . "," . $_POST['field2'] . "," . $_POST['field3'];
The $_POST [php.net] array holds all the data posted to the script. You access them as above with the element name from the form replacing field1/2/3. You concatenate them together in the order you want putting a comma in between.
$fp = fopen [php.net]("/dir/file.csv","a");
This will open the file for append. You need to change the /dir/file.csv to the path to the file you want to write to.
fwrite [php.net]($fp,$writetocsv);
This writes the content of the variable $writetocsv to the file.
fclose [php.net]($fp);
closes the file handle.
pretty straight forward.
Not really. The way some thing like this is *normally* done is .. the form submits data to your secure server .. and your secure server in turn connects to the processor's server and posts data and gets response from there and shows it to the user.
The thing is, what we have NOW works. And Authorize.Net has told us it will continue to work so long as we set up a secure connection to POST from. So, I'm trying to keep what we have that I KNOW is working and add the write to file function. The only change I want to make to our basic form is for it to collect the CC # and expiry date as well as the rest of the billing information that it already collects. Authorize.Net has POST variables defined for the fields, we just haven't been using them because we've been collecting the basic info on our non-secure server to avoid the extra hassle of setting up the secure server.
I've looked through the Authorize.Net interface documentation. I just located some example scripts that they have. I'll be looking through those after I wake up (work "ended" an hour ago and "starts" again 6 hours from now).
Gerald
Welcome to WebmasterWorld Phorce1
Thank you for the welcome. I'm glad I found you. I think I'll be spending some time here, helping where I may be able to. Lots of reading to catch up on.
How about the quick and dirty script example for writing to a file.writing to a file is pretty simple. open it, write it, close it.
I'll be checking your examples as I get back into the php swing. I haven't been doing the web work here at the company I work for, I'm a customer support and hardware/linux tech. My personal site is just a small bit of html as a front for what is mostly photo albums generated on my linux box by "album" from Dave's Marginal Hacks. I did a whole lot of bash/sed scripting around my use of 'album' to alter the generated html but none of it is server side.
Thanks again,
Gerald
[edited by: jatar_k at 3:25 pm (utc) on June 8, 2003]
[edit reason] no urls thanks [/edit]
Jatar_K, THANK YOU for the quick and dirty $writetocsv example you gave, it worked like a charm! Unfortunately, only for the first record... and then each subsequent record was appended to the first/prior record in the last column in the csv file. For instance:
EmailAddr_ / FirstName_ / LastName_ /
Email 1 / First 1 / Last 1 /
/ Last 1+Email 2 / First 2 / Last 2 /
and so on...
But, I need the data from each form submission to begin in a new row so it will look like this:
EmailAddr_ / FirstName_ / LastName_ /
Email 1 / First 1 / Last 1 /
Email 2 / First 2 / Last 2 /
Email 3 / First 3 / Last 3 /
...etc.
How can I get this done? I appreciate any additional help you can give.
<form id="order_form" submit="form_sub.php" onsubmit="Ajax.submitForm('order_form', '',{method:'post', url:'/form_sub_2.php', async:false});">
</form>
You will find many Ajax.submitForm functions prebuilt... YUI and Spry both have one.
I am using this method in a few places and find it more elegant then having the first submit page do the work of two.
[edited by: Demaestro at 9:38 pm (utc) on Feb. 14, 2008]