Solved

Script that can take form results and put it in a csv file and then email form results

Posted on 2002-06-25
13
211 Views
Last Modified: 2013-12-25
I'm at my wits end with this script that I'm using but unable to get it to successfully email the form results to recipient list. If you go to http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=perl&qid=20311313 you will see the question posted there but still unresolved.

A brief on what I'm trying to accomplish.

I use a Perl script that will take users input from an html form. The perl script takes the form results and put it into a comma-separated flat database (csv file). I need to get the form results emailed to a recipient list, so I use $mailresults and point it to use the basic FormMail.pl as the form emailer but I keep getting into a "bad referer" problem ... Please read http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=perl&qid=20311313 and you will see the problem in details.

I've decided to post here to see if someone may be able to help, or come up with a better cgi script that'll handle emailing the form results to the recipients and updating the flat-comma-separated-database (csv file) with the results entered from the form.

If any one should have any issue with the post in the Perl fora and think I should resolve it first before getting any successful answers here, I'll close/award points/whatever ...

Thanks for the time and input.
-jamaica-
0
Comment
Question by:jamaica
  • 7
  • 5
13 Comments
 
LVL 15

Expert Comment

by:samri
ID: 7108172
jamaica,

I have looked at the thread, and to be honest, I tend to get "lost" halfway.

So, I would prefer to start from fresh.

You have a page, where people would fill up the form and submit the form.  These data would be appended to a flat csv file.

At this point, did you want the scripts to mail the content of the data, and write it to the csv file, or write to csv file, and mail the whole file.

For example, you form would have: username, password, DOB, and the csv would look like;
---
samri,samri1234,19700101
jamaica,jamaicapassword,20000101
name,password,dateofbirth
---

Let say a user fill's up a form;
newuser,newpassword,111122333

Do you wan to information to be mailed to webmaster@yuorsite.com, upon clicking "submit", and the data is appended to the csv file.  OR, update the csv, and send all the content of the csv.

-Apology if this causes you to repeat the whole thing all over.  I haven't got a chance to try FormMail.  I heard that it's quite popular, but I would rather work something from scratch.

cheers.
0
 

Author Comment

by:jamaica
ID: 7108400
Yes,this is exactly how I want the form to be done...

"the info information (entered in the form) to be mailed to webmaster@yuorsite.com, upon clicking "submit", and the data is appended to the csv file."

I use readcsv.pl to convert the csv into html and the link is sent in the mailer to the recipient(s).

Thank you so much for your help!
0
 
LVL 15

Expert Comment

by:samri
ID: 7108464
Jamaica,

Just give me some time to work it out.  I should come it with a rought scripts and hopefully it would work for you.

--(now I need to go to bed :(
0
 
LVL 15

Expert Comment

by:samri
ID: 7108465
Jamaica,

Just give me some time to work it out.  I should come it with a rought scripts and hopefully it would work for you.

--(now I need to go to bed :(

and hopefully, somebody else might be able to help too :)
0
 

Author Comment

by:jamaica
ID: 7108584
thank you samri, I need help bad!
0
 
LVL 15

Expert Comment

by:samri
ID: 7109579
Jamaica,

Apology for being so slow on this.  After going thru the original thread, it looks like lexwern has tried to work on the FormMail, but still no luck on you side.

-- Some comments, from the Original Question thread.

I decided to add the following line
require='usr/local/opt/abcxyz/abc.xyz.com/cgi-bin/FormMail.pl

This line executes FormMail.pl and emailed the form's results BUT it did not write the results to the csv file.
I got an error from the perl script that handles the csv file that the script was executed from html.  I have a print "Content-type: text/html","\n\n"; in the csv.
---

So it does work (mail got sent out) when you use "require" approach.

Could you try to add the "require" line, after you call the function to modify the csv.  Personally, I used to come across a situation where the FORM Data is missing after calling some perl modules (via use statement).

Another option is to assign the FORM data (that needs to be written to the csv explicitly.

I would say it's much straight forward to debug the csv printing than formmail at this point.

give it a shot.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:jamaica
ID: 7112136
Yes, when I used "require" the mail got sent but the csv wasn't created.

Well, it has now turned out that the email notification is needed when the user selects a specific checkbox, e.g., there's a "Yes|No" checkbox on the form. If the user selects "No" then an email notification needs to be sent to a recipient notifying that the client selected "No" and immediate follow-up can be done at that point ...

My brain is fried right now and I can't think of an approach to take with that ... do a CGI script that'll send out an email notification if "No" checkbox is selected?  That's a whole different can of worms now.
0
 
LVL 15

Expert Comment

by:samri
ID: 7115773
jamaica,

I bet you must be almost giving up :(

Well, we know that the email notification is needed only when the check-box is "checked".  I think it is possible to examine the content of passed variable, an only send email if the radio button is checked.

0
 

Author Comment

by:jamaica
ID: 7117215
No, have not given up but I've found a dirt cheap way to do it!

I inserted this into the perl script that creates the csv
===== THIS IS INSERTED IN THE create csv ====

open (MAIL, "| /usr/lib/sendmail -oi -n -t" );
print MAIL <<MAIL_MESSAGE;
To:myemail\@whatever.com
From:you\@wherever.com
Subject: Just to notify

whatever goes here and it is sent in rich text format

MAIL_MESSAGE

close MAIL;
==========================

The dirt cheap way is using MSE-Exchange to auto-fwd the notification mail to the recipient(s). The rules wizard allows me to specify by subject, or look for text in the body and forward the notification to anyone I need it to go to. The main thing is the csv is converted to html and there's a link to the html page in the notification mail.

Maybe I should close this thread then?

I'll be back here later in the day and close with "jamaica has found a resolution for the question"
0
 
LVL 15

Expert Comment

by:samri
ID: 7117377
Jamaica,

Yup.  Since you already got a "working" solution, there is no point in keeping the Q open, unless you are still waiting for a much "cleaner" solution.  

At this point, since you had "solved" your own problem, and you cannot "award" yourself the pts, you could request for a deletion to this question.

Alternately, you request for a refund to your pts from Community Support (http://www.experts-exchange.com/commspt/) since that is the only way to keep the Q in PAQ.  This is better since other members could search the PAQ later.

http://www.experts-exchange.com/commspt/

cheers.
0
 

Author Comment

by:jamaica
ID: 7122403
Deletion request will be done.

Thank you again samri for your time. You and many others are the reason why I love this board, your selfless, timeless effort to make suggestions and help resolve a technical problem for another person!
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7122443
Points refunded and question closed.

Netminder
CS Moderator
0
 
LVL 15

Expert Comment

by:samri
ID: 7123786
No prob.

That is the reason why we are all here.  To help each other (gee.. do I sound like a preacher :)

cheers.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now