Re: OT: How to get form input results written to a file?

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (text/plain)
Delete this message
Reply to this message
Author: Lisa Kachold
Date:  
To: Main PLUG discussion list
Subject: Re: OT: How to get form input results written to a file?
Hi Joe!
...

Let's go brainstorm the possibilities:

On Thu, May 2, 2013 at 4:15 PM, <> wrote:

>
> How to get form input results written to a file?
>
> On one of my websites, I use the html "form input" code shown below
> for visitors to input their email address to be emailed to me. This
> works fine.
>
> What would I need add to this code to get the same submitted
> information written to a file in my web hosted space on my web
> host's server in addition to having the information sent to me by
> email?
>
> <form action=http://www.bluehost.com/bluemail method=POST>
> <input type=hidden name=sendtoemail value=>
> Please enter your email address:<p>
> <input type=text name=mailfrom size=30 maxlength=70>
> <input type=submit value=Send>
> </form>
>


It appears you are using bluehost's mailer called BlueMail. This email
form help request would be most effective posted to Bluehost's support
forums? http://www.bluehostforum.com/archive/index.php/t-432.html

Of course, you can't simply tell it to echo $mailfrom to a file? Not
without invoking php or another system call.

I am sure you don't HAVE to use BlueHost's BlueMail CGI; HTML mail forms
are pretty fun to write and use, however bluehost might have some peculiar
constraints for obvious security reasons?

Basic BlueMail How to:

Log into the cPanel navigate to the CGI center. In the cgi center click
on BlueHost.com. On the BlueHost.com page, there is a functional form.
Modify the email address listed in the default example to one on your
account. After saving this form to a file, and uploading it, test it. Once
successful modify to fill needed requirements. Please note the critically
important parts are in the first couple lines, and the last few lines of
the code for the form. The BlueHost.com page contains additional details
about other available fields. Most standard form mail fields are
acceptable to use.

Remember Bluemail will only send messages to an email address setup on your
Bluehost account. If you wish to deliver the email elsewhere, you may setup
an email forwarder instead. OR USE another cgi!

Here's a full well written explanation of using HTML forms:
http://www.w3.org/wiki/HTML_forms_-_the_basics - You can make some nice
tricked out form fields and buttons!

Clearly you should have PHP available, so you can use a nice expanded radio
button jazzed up script/form that allows your users to upload a file that's
sent with the email, or writes to a file (as you want). James Huggins
developed and runs one on a BlueHost (that gives you the option of saving
to a file as well as emailing out form field input).

http://www.jamesshuggins.com/h/hefs/huggins-email-form-script.htm free
Of course you can also use PERL (which they also have available); just
place the scripts into the directory parallel to public_html or in the
directory under public_html/cgi-bin (just use whichever is already setup
there) and make sure that the script file has executable permissions (755)
and then check to see that you have enabled exegCGI in your management
portal. You might verify the location of perl with a command line "which
perl" if you have ssh access. According to some of the other users on the
forums, in order to use server side includes with perl, you will need to
specify "#!/ramdisk/bin/perl" as the first line in each script (rather than
the #!/usr/bin/perl line). You should be able to test run your scripts via
"perl scriptname" (it might give an error as it expects input), to ensure
it runs.

#!/ramdisk/bin/perl
# form2file.pl CGI
# Sporked from Various HowTo's
# ActionOnline/2013
# Called from HTML path/filename

use strict;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);

# Parse Form Data
# Requires a matching $variable for each of your form input questions

my $mailfrom=param("name");

# For example to add additional entries to be saved from your form:
# my $comment=param("comment");

open(FILE, ">>file.txt") || die "can't write to file.txt $!";

print FILE "$mailfrom\n";
print FILE "\n";

close(FILE);

print header(),
start_html(-title=>'File Created'),
'File created!',
end_html();

# end


NOTE: The most frequent snafu's met with cgi-scripting are PATH based!
Try both server side paths ["../cgi-bin/form2file.pl"] and URLs ["
http://www.myhost.com/cgi-bin/form2file.pl" since you can't see how the
server is setup usually related to server side scripting and security -
it's fastest to try. Also watch for permissions and be sure that you can
run the scripts locally if you have ssh!

*So that will create your file info, but what about email? Surprise! *
*
*
*Using Javascript you can invoke both the perl script-let below and the
bluemail tool:*


############################Start JavaScript 2 Script
Submit###############################
<html>
<head>
<script language="Javascript">
<!--
function OnButton1()
{
    document.Form1.action = "http://myhost.com/cgi-bin/form2file.pl"
    // document.Form1.target = "_blank";    // Open in a new window


    document.Form1.submit();             // Submit the page


    return true;
}


function OnButton2()
{
    document.Form1.action = "http://www.bluehost.com/bluemail"
    document.Form1.target = "_blank";    // Open in a new window


    document.Form1.submit();             // Submit the page


    return true;
}
-->
</script>


<noscript>You need Javascript enabled for this to work</noscript>
</head>
<body>
<!-- create the form -->


<form name="Form1" method="post">

<!-- Add the data entry bits -->

<input type=hidden name=sendtoemail value=>
Please enter your email address:<p>
<input type=text name=mailfrom size=30 maxlength=70>

<!-- Add some buttons -->
<INPUT type="button" value="Button1" name=name onclick="OnButton1();
OnButton2();">
<!-- close the form -->
</form>
</body>
</html>

# End Javascript example

>
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>




--

(503) 754-4452 Android
(623) 239-3392 Skype
(623) 688-3392 Google Voice
**
it-clowns.com
Chief Clown
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss