PDA

View Full Version : Sumbitting Multiple Fields/Files by email


travisperkins
02-10-2006, 09:46 AM
I have created an application, that is a training course with multiple pages. On each page, the user is given some information and asked to enter a reply by typing text into a text box which is then saved to text files in AutoPlay/Docs.

The text boxes are therefore 'Input1', 'Input2', 'Input3', which are on Page 1, Page 2, Page 3 of the application and which save to AutoPlay/Docs/Text1.txt, AutoPlay/Docs/Text2.txt and AutoPlay/Docs/Text1.txt

The user can come back and edit any of their pages at any time.

When they have finished the whole course, I want them to be able to submit their answers online, so I receive them by email. But it seems a bit cumbersome to ask them to open up AutoPlay/Docs, gather and zip up all their text files and then send them in. In fact, I wouldn't get away with it professionally even if I felt comfortable with it.

Preferably, I would like them to be able to just click a Button that I pro-configure to submit the text to an email address. So, when they click 'Submit My Course', all of the text files get gathered up and sent in.

Can this be done?

I would like the flexibility, in a perfect world, to move away from receiving the answers by email to having them submitted directly to a MySQl data base. Otherwise, me and my other teachers have got to open up a seperate text file for each question and read it. I would like to wait until I am a bit more experienced for that; I mention it here in case that influences the method used now. That said, if there are examples of submitting multiple text files to a data base, I would sure like to know.

Any pointers, code snippets or links would be very much appreciated.

bule
02-10-2006, 10:39 AM
Using MySQL is a good idea for this. However, you should be familiar with SQL language (to use query and submit functions properly). To use MySQL in APMS you can use this guide. (http://www.indigorose.com/forums/showthread.php?t=14878)

travisperkins
02-10-2006, 11:31 AM
OK.

I would like to see if I can get multiple text boxes submitted by email first. Then I'll see if I can do it with mysql.

Anyone know if it is possible. I am currently seeign if I can adapt the example here:

http://www.indigorose.com/forums/showthread.php?t=9454

travisperkins
02-10-2006, 11:55 AM
I am struggling because there appears ot be a problem with the example emailer.apz given to download at http://www.indigorose.com/forums/showthread.php?t=9454

This example works, but the actual body of the email that arrives is always blank and does not cotnain the text entered by the user.

I am not talking about any adaptation of this example, I mean the untouched pristine example as downloaded.

travisperkins
02-10-2006, 12:10 PM
Does anyone know what is going wrong here:

Using the exampel downloaded from a thread, I have an example email/php application.

On the web server I have a php script containing:
____
<?php

// specify recipient email address
$to="biz@karazoo.com";

// send our email
mail ("$to","$subject","$body","$from");

?>
___

On the page of the AM6 application I have three input fields as given in the example.

On the 'Send' button on click event I have:

______
-- clear error variable
error = 0;

-- Get values from input fields
from = Input.GetText("Input1");
subject = Input.GetText("Input2");
body = Input.GetText("Input3");

-- check for empty fields and deliver errors if needed
if String.Length(from) < 1 then
Dialog.Message("Error", "Please enter your email address and re-submit. Thank you.");
error = 1;
end
if String.Length(subject) < 1 then
Dialog.Message("Error", "Please enter your email subject and re-submit. Thank you.");
error = 1;
end
if String.Length(body) < 1 then
Dialog.Message("Error", "Please enter your email message and re-submit. Thank you.");
error = 1;
end

if error~=1 then
-- if no errors exist, send the email now and give a confirmation dialog
HTTP.Submit("http://www.karazoo.com/mail.php", {from=from, subject=subject, body=body}, SUBMITWEB_POST, 20, 80, nil, nil);
Dialog.Message("Success", "Success, your info has been submitted.");
Application.Exit();
end

_____

But when I submit, I reveive an email at my email address that is from 'Nobody', has no subject and an empty body.

I have uploaded the example.

travisperkins
02-10-2006, 12:33 PM
I have found another example that may work well for me, and have attached it to this post.

Could someone just tell me where in the AM6 code of this example do I enter the web address of the php mailer script that I have uploaded to my server accroding to the instructions at:

http://www.indigorose.com/forums/showthread.php?p=75127

bule
02-10-2006, 12:38 PM
Try this to fix your error in previous code:

if error~=1 then
-- if no errors exist, send the email now and give a confirmation dialog
HTTP.Submit("http://www.karazoo.com/mail.php", {"from="..from, "subject="..subject, "body="..body}, SUBMITWEB_POST, 20, 80, nil, nil);
Dialog.Message("Success", "Success, your info has been submitted.");
Application.Exit();
end

travisperkins
02-10-2006, 12:44 PM
No. Unfortunately, the same thing happens.
I get an email no problem: but No Subject, No body and it is from 'Nobody'

Does it work for you?

travisperkins
02-10-2006, 12:49 PM
Actually, when I add this code that you post, there is an error that says "Invalid field for 'next'"