Closed Thread Icon

Preserved Topic: Form handling (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=21048" title="Pages that link to Preserved Topic: Form handling (Page 1 of 1)" rel="nofollow" >Preserved Topic: Form handling <span class="small">(Page 1 of 1)</span>\

 
Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 01-08-2002 22:07

I'm pretty new to the web scene and I'm kind of learning as I go...I don't know if this question should go here or not. I'm hoping some of you gurus can help me out. I have a form that's basically a one question survey. I want the result of each submission to be returned to me via email....I know that this can be done with some Javascript, but I'm confused as to which browsers it works in and my email client doesn't really cooperate with me when trying to test it...I know it can be done with Server Side Scripting (Perl) because I read through the archives and found a good link that Max gave awhile back. After reading that, I don't know what to do. The Perl script seems really involved and I don't want to screw around on the server while I don't really know what I'm doing....Opinions please???
Thanks.

Edit>And here's that great link from Max: http://bignosebird.com/carchive/bnbform.shtml

[This message has been edited by Jeni (edited 01-08-2002).]

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 01-08-2002 22:30

Well, you didn't mention if you were using straight HTML with a CGI form, or if you are using PHP. I like PHP because I think it's easier for stuff like this. If you could clarify your platform, we can probably assist you better.

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 01-08-2002 22:46

I dont' know about that particular script, but perl scripts such as that are generally fairly straightforward to install and use.

It's likely that your ISP already offers a form processing script, you should ask if they have any scripts available. Otherwise it's really not that hard to install and use a script _IF_ your ISP allows it. Another possibility is to have a 3rd party host provide you with the script (it says something about that at the bottom of the link you gave).

At any rate, you will need some sort of server-side solution for this because javascript just wasn't meant for this sort of thing.

-jiblet

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 01-08-2002 22:54

Well, without a server side script (perl, PHP, ASP etc....) you can't send form input through an email to yourself.

You see, when you submit a form the information get sent to the web server (mostly) so you need some kind of server application to recieve the data from the form, process it and then send that data via email to it's desternation. That application is usualy a web programming application or extention for the web server software. So, you need to know what you have access to on the server your using and then you need to know how to use it.

Like Pugs said, PHP is good and simpler in many respects than perl. However if you don't know what you have to work with or you don't want to leap into the server side of web development there are other ways. There are many many websites that offer server side services and the like for free. Usualy at the cost of a small add here or there but they've already done the hard work for you.

You can sign up with them and create an account similar to how you would sign up for a free web mail account. Then you can select various web-app like programs to use on your web site. You'll have to make the forms yourself but they'll have mini tute's and how-to's for all of that stuff.
www.bravenet.com is a popular one that comes to mind if you want to try it out.

I've use them quite a bit in the past and their stuff worked well but, I don't need them anymore

If you want to do the server side work yourself get back to us with what server side languages the server your hosted on is running and we'll help you get up and running .

Good luck.

Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 01-09-2002 15:06

Thanks for all the responses and patience
It's a straightup html page currently (with that little bit of JS).
Here is the raw page so that you can view the code. I use a little php on my own site, but I don't know how to write it.

Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 01-10-2002 14:20

I'm not sure if I understand what you mean by "platform". I can use PHP on my web server..

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-10-2002 14:35

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-10-2002 14:42

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 01-10-2002 14:43

YES YES YES. Thank you.
I have used PHP before so I think I'd be a little more comfortable with it compared to the others.

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 01-10-2002 16:03

So you have PHP? Here's a function I use to gather up form fields:

function gatherOutput() {
global $HTTP_POST_VARS;
reset($HTTP_POST_VARS);
$maxLength = 0;
while (list($key,$value) = each($HTTP_POST_VARS)) {
if (strlen($key) > $maxLength) $maxLength = strlen($key);
}
for ($i=0; $i < $maxLength + 3; $i++) $emptyRow .= ' ';
reset($HTTP_POST_VARS);
while (list($key,$value) = each($HTTP_POST_VARS)) {
if ($value != '' && $key != 'Submit') {
$value = preg_replace ('/(\r\n)/',"\\1$emptyRow",$value);
if (is_array($value)) {
$firstRun = 1;
foreach ($value as $item) {
if ($firstRun) {
$pendingValue = $item;
$firstRun = 0;
} else {
$pendingValue .= "\r\n$emptyRow$item";
}
}
$value = $pendingValue;
}
$spacer = ' ';
for($i = 0; $i < ($maxLength - strlen($key)); $i++) $spacer .= ' ';
$output .= "$key$spacer: $value\n";
}
}
return $output;
}

If you use a monospace font, this will make all the field values line up in the email.

I have this code in a file that I include(); Then on each individual form processing page I have some code like this:

$emailRecipient = "schul182@umn.edu, dasil003@tcsu.umn.edu";
$emailSubject = "Alumni Group Event Registration Form";
$emailHeaders = "From: TCSU Alumni Group Webpage\nReply-to: $email";
$emailBody = gatherOutput();
mail($emailRecipient, $emailSubject, stripslashes($emailBody), $emailHeaders);


-jiblet

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-10-2002 16:16

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 01-10-2002 16:27

Okay...I don't know if I'm doing this right or not...here's my page with my form on it : http://www.sofsole.com/pages/spanish.php

Here's the "process mail.php" file code:

<?
// User-defined Variables
$emailRecipient = "jeni@4implus.com";
$emailSubject = "Spanish Form";
$emailHeaders = "Spanish Form";
$emailBody = gatherOutput();
mail($emailRecipient, $emailSubject, stripslashes($emailBody), $emailHeaders);


//begin script
function gatherOutput() {
global $HTTP_POST_VARS;
reset($HTTP_POST_VARS);
$maxLength = 0;
while (list($key,$value) = each($HTTP_POST_VARS)) {
if (strlen($key) > $maxLength) $maxLength = strlen($key);
}
for ($i=0; $i < $maxLength + 3; $i++) $emptyRow .= ' ';
reset($HTTP_POST_VARS);
while (list($key,$value) = each($HTTP_POST_VARS)) {
if ($value != '' && $key != 'Submit') {
$value = preg_replace ('/(\r\n)/',"\\1$emptyRow",$value);
if (is_array($value)) {
$firstRun = 1;
foreach ($value as $item) {
if ($firstRun) {
$pendingValue = $item;
$firstRun = 0;
} else {
$pendingValue .= "\r\n$emptyRow$item";
}
}
$value = $pendingValue;
}
$spacer = ' ';
for($i = 0; $i < ($maxLength - strlen($key)); $i++) $spacer .= ' ';
$output .= "$key$spacer: $value\n";
}
}
return $output;
}
// End script
?>

Now, does anyone know why this seems to not be working properly?
1. It takes awhile to seemingly process it online
2. It kicks you to a blank page when it's done
3. I didn't receive an email


Pweeeeze help me

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-10-2002 16:43

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-10-2002 16:49

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 01-10-2002 17:17

Thanks so much for all your help. This is embarrassing. That test page didn't do anything. What do I need to do?

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-10-2002 17:31

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 01-10-2002 17:45

hehe well it's an external (rented) and I'm looking at all the cpanel stuff and it seems like we have everything a gal could want ya know? (Most of it, I don't know what to do with, naturally)...hehe
I did try it with other email addys and it doesn't appear to be working, so I'll try to find out if its disabled.

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 01-10-2002 18:06

Sorry, that code is a little rough to expect it to just work. I left out many details (which Ini has kindly pointed out).

One thing, you DON'T need to put the gatherOutput() function before the user-defined variables. Just in the way of explanation, the gatherOutput() function does the following things:

It uses $HTTP_POST_VARS which is an array that contains all the form elements of a form submitted with the POST method (defined in the form tag).

It loops through those variable names (ie form field names) to determine which is the longest.

It resets the array and loops through again printing each key/value pair. Most of the code actually is just there to print the proper number of spaces after each field name so that the values all line up.

One other detail is that it ignores fields named "submit" because that is generally the submit button, and you don't usually care about that value.

The test function Ini gave you is good. PHP must be configured to allow use of the mail() function for you to have any hope of doing this in PHP. One reason it might be disabled is because poorly written scripts can allow spammers to use your form processor to spam thousands of people before the admin discovers it. The thing that makes my code safe is that the $emailRecipient is set explicitly in the code. If the recipient were passed through a variable at any point then it would be easy to abuse.

U might consider posting a screenshot of the options on your admin tool (with any sensitive information blurred out of course) to see if we can find any clues. Emailing the admin team is probably the simplest solution though.

-jiblet

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 01-10-2002 18:11

Try naming the file with a php3 extention, and make sure that you try using the full PHP tags, like this:

<?php
mail("jeni@mail.com", "this is the subject", "this is the body");
?>


Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 01-10-2002 18:23

jiblet....sorry...I don't understand the code well enough to pick through it...I shouldn't have tried to just plug and play there ...I'll keep it and maybe be able to get some good use out of it in the future when I better understand php...I have submitted a question to tech support and we'll see what comes of that...I also tried the PHP3 extension and no dice ....

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 01-10-2002 19:36

Jeni,

If you want to go back to using the Big Nose Bird form, I can help you. I am using this same form on a site that I am doing for a friend of mine.

You can see a real rough draft of it here.

Test it out it will send you an email telling you that the message was sent and all that stuff and then send me an email with all the info. I can forward the email to you that was sent to me so you can see what it looks like.

Big Nose Bird is a really nice form but can be really pick about how it is uploaded.

Just let me know.

Later,
C:\


~Binary is best~

[This message has been edited by CPrompt (edited 01-10-2002).]

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-11-2002 13:43

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 01-11-2002 16:20

I am waiting on my server to tell me why it isn't working
This is for a commercial site and I don't think they'd take kindly to the banner ads Dracusis spoke of, so I really want to try PHP....I'm waiting to hear back from tech support

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-11-2002 16:36

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 01-11-2002 17:15

To make it easiest on all of us...I'm going to give them over the weekend to respond...I'll reasess the situation on Monday. Thanks for all your help.

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 01-11-2002 23:51

I just want to point out that my script, although cumbersome to understand is quite simple to implement. The reason it didn't work was because mail() didn't work. You basically had the right idea though.

-jiblet

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-17-2002 10:14

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 03-14-2002 18:20

I hate our webserver. It's taken long enough, but I got the test file to work. Sooooo InI, I'm ready. What next?

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 03-14-2002 18:50

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 03-15-2002 09:16

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 03-15-2002 10:26

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Jeni
Paranoid (IV) Mad Scientist

From: 8675309
Insane since: Jul 2000

posted posted 03-15-2002 13:45

Thanks so much InI. I'm gonna plug that in and test it out, and yes, I would like *all* of the fields to be required...

Ducati
Paranoid (IV) Inmate

From: in your head
Insane since: Feb 2001

posted posted 03-15-2002 15:40

Good thread....

Excellent link MrMax!

:: m a x ::

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 03-18-2002 19:01

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

« BackwardsOnwards »

Show Forum Drop Down Menu