CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Perl beginner - I need help please

 

First page Previous page 1 2 3 4 5 Next page Last page  View All


mhx
Enthusiast / Moderator

May 23, 2001, 6:12 PM

Post #26 of 123 (8922 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

> 1.What’s the difference between Formmail and Sendmail?

The difference is (at least for me): I know sendmail, but I don't know formmail ;-) Sorry I can't help you with that.

> 2.Can I use any email through Sendmail? E.g. hotmail accounts?

I don't know exactly what you mean here, but if your point is whether you can send mail to any accounts, the answer is yes.

> Set the file permissions on the cgi script file and directories to be 'chmod 755'.
> 3.What does this mean? How can I do this?
> I read it has something to do with FTP. I use WSFTP.

It's not so much about FTP. Apache at netfirms is configured to accept only files with certain permissions. But you can use your FTP client to set the permissions using the chmod command.
I've been working with WSFTP some years ago until I discovered LeechFTP, which I find much easier to use. If you like to try it, it's free.
Using LeechFTP, you can send a chmod command by right clicking on a remote file and selecting 'Set Attributes...'. 755 is Read and Execute for everyone and Write only for Owner.

> 4.Would it be better to have my Form call my .cgi program to send me the mail?

Yes, I think so. You should place the form in your HTML file and use the cgi script only for sending the mail.
CGI-only sites are only useful if most of the content is dynamic. If there's lots of static stuff, you should separate HTML and CGI.
I've written a CGI-only website. It's a small search engine for my DVD collection. And it's in german ;-) There's not a single HTML file, only two CGI scripts managing the whole site. (Plus an admin & statistics script, but these are only for me.)

Bye,
Marcus



JennyW
journeyman

May 24, 2001, 5:56 AM

Post #27 of 123 (8912 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

I used to use Leetch, but then I moved to WSFTP. I had a lot of login problems with Leetch. Basically, it wouldn’t let me login to certain ftp clients once in a while.

I have a few questions for you…
1. I uploaded my a Form to…

http://jennyw.netfirms.com/

I used .cgi code (link) below…

http://members.home.net/pie3.14/AlphaMail.txt

I ONLY adjusted the settable variables, the shebang line and the line under it.
Line under shebang line

Code
use CGI::Carp qw(fatalsToBrowser);

I can’t get my Form to work. I always receive this error…

In Reply To
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, Your Webmaster and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

I know I have the location of perl and sendmail correct. I’ve also set my .cgi file permissions to 755.

2. Am I suppose to do anything with either of the following?


In Reply To
CGI Url
http://domain.netfirms.com/cgi-bin/file.cgi

Your full or absolute root path is:
$ENV{'DOCUMENT_ROOT'}

Remember to use double quotes around the path.
The full path to your www directory would be:
"$ENV{'DOCUMENT_ROOT'}/www"
The full path to your cgi-bin directory would be:
"$ENV{'DOCUMENT_ROOT'}/cgi-bin"

Should I be looking at this file for anything…

http://jennyw.netfirms.com/cgi/printenv

3. My .cgi file used to be a .pl file, but I just saved it as a .cgi document? Is that ok?

Some similar questions…

Using netfirms.com
4. If I have html documents that call on .cgi docs then what folder do I put my pages in?
Do I put them all in the same folder? Or do html docs go in the /www folder and .cgi docs in the /cgi-bin ?

5.

In Reply To
You wrote…
I've written a CGI-only website. It's a small search engine for my DVD collection. And it's in german ;-) There's not a single HTML file, only two CGI scripts managing the whole site. (Plus an admin & statistics script, but these are only for me.)

How do YOU upload your .cgi scripts to netfirms.com?

In Reply To
Netfirms.com writes…

You must place all your html and image files in the 'www' directory. Only files placed in the 'www' directory can be viewed on your website. Keep all filenames in lowercase characters.

I tried uploading the .cgi email catching script you gave me to netfirms, but it didn’t work. The page wouldn’t come up when I called it in the browser.

http://members.home.net/pie3.14/email_catching.txt

And finally

6. I write my files like this…

# URL to go to if there is a problem with form input
$ErrorPage = "a_fail.html";

But some of the files have a slash ( / ) in front of the file name, so should I have a slash before the file name?

$ErrorPage = "/a_fail.html";

Thanks for taking the time,
Jenny



JennyW
journeyman

May 24, 2001, 12:03 PM

Post #28 of 123 (8904 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

Ok, I found answers to questions 3, 4 and 6. So disregard those.

Thanks,
Jenny



mhx
Enthusiast / Moderator

May 24, 2001, 12:29 PM

Post #29 of 123 (8902 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I've written this offline and it took a while. I wouldn't want to delete the already answered questions... ;-)

> I had a lot of login problems with Leetch. Basically, it wouldn’t let me login to certain ftp clients once in a while.

Interesting... I'm using it for years now, and I didn't have any problems. Anyway, I think you'll be happy with WSFTP, too.

> I can’t get my Form to work. I always receive this error

First, the modifications to your file were (mostly) correct (see below).
This error mostly shows when there's a problem with the file rather than with the source code.
There were two problems: First, you have to convert all your CGI-scripts to Unix format. The file you linked to was in DOS format, meaning each line was terminated by a CR/LF sequence, while lines in Unix files are only terminated with a LF character.
To do this conversion, you can use a good text editor (e.g. UltraEdit, use File / Convert / DOS to Unix) or the following script:

Code
#!/bin/perl -w 

undef $/;
$file = shift || 'filename.cgi';

open FILE, $file or die "cannot open $file: $!\n";
$_ = <FILE>;
close FILE;

rename $file, "$file.bak";
s/\r\n/\n/g;

open FILE, ">$file" or die "cannot open $file: $!\n";
binmode FILE;
print FILE;
close FILE;

Provide it with the name of the file you'd like to convert as the first parameter.
The second problem I discovered is that CGI files at netfirms need to be mode 700 instead of mode 755. By the time I registered at netfirms, they also wrote 700 on their page. Perhaps they're making a transition here and it'll work with 755, but if you change to 700 I think you're safe.

> Am I suppose to do anything with either of the following?

No, not really. You should keep in mind that when you reference from HTML to CGI you must use cgi-bin/file.cgi instead of plain file.cgi and when you reference from CGI to HTML, you must use ../file.html instead of plain file.html. So, in your script you should rather write

Code
$ErrorPage = "../a_fail.html";

instead of

Code
$ErrorPage = "a_fail.html";

if a_fail.html is in your www directory.

> http://jennyw.netfirms.com/cgi/printenv

Are you sure with this url? Shouldn't that be http://jennyw.netfirms.com/cgi-bin/printenv.cgi?

> 3. My .cgi file used to be a .pl file, but I just saved it as a .cgi document? Is that ok?

Absolutely.

> 4. If I have html documents that call on .cgi docs then what folder do I put my pages in?
> Do I put them all in the same folder? Or do html docs go in the /www folder and .cgi docs in the /cgi-bin ?

Separate them. The cgi-bin is for CGI scripts, logs, data accessed by CGI scripts, Perl libraries, etc.
The www is for all your HTML, CSS, pictures, files that can be downloaded.

> How do YOU upload your .cgi scripts to netfirms.com?

Actually, I've written a tricky upload script in Perl. That's because first, the site has lots of images, and I don't want to keep track of which of them I have updated locally, and second, I can't (and don't want to) remember when I locally modify my scripts.
Well, my upload script first connects to the netfirms server, recursively retrieves a list of all files on the server, retrieves such a list of the local files on my machine, and checks which files are different. If files differ, it is assumed that the local files are up-to-date. These files are uploaded. If files are available locally, but not on the server, these are uploaded, too. If files are available on the server, but missing locally, these files are removed from the server.
The script also converts all my CGI scripts before uploading so they will have the right shebang line. And last but not least the script sends a chmod 700 for every uploaded CGI script.
Using this script saves me from worrying about synchronization of local and remote files and also saves my money because it significantly reduces my internet costs ;-)
If you're interested in the script, tell me. But be aware that you surely will have to modify it before you can use it. As I said it's a quite tricky sort of script.

> I tried uploading the .cgi email catching script you gave me to netfirms, but it didn’t work. The page wouldn’t come up when I called it in the browser.

Well, I also tried it and it showed up. I don't know if it actually works, but at least it showed up. Are you sure it hasn't got something to do with Unix format or mode 700?

> But some of the files have a slash ( / ) in front of the file name, so should I have a slash before the file name?

Normally files don't have slashes in front of their names ;-) The slash only indicates that the file is located in the root directory. I don't believe this is correct. But, as I mentioned above, you should reference the file from the CGI script as if it was located in the parent directory (../).

Bye,
Marcus

P.S.: There's a successor to LeechFTP, called BitBeamer (ftp://ftp.cuhk.edu.hk/.1/chinese/cpatch/ftp/bitbeamer/bitbeamer2001.exe), which has a synchronize option. This should be quite similar to my upload script, except for modifying scripts and the chmod. It's still in beta state, and I haven't tested it. Since I don't know if WSFTP has a synchronize option, perhaps this is interesting for you.

(This post was edited by mhx on May 24, 2001, 1:06 PM)


JennyW
journeyman

May 24, 2001, 8:11 PM

Post #30 of 123 (8893 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee Marcus. Thanks so much for the giant reply. I can’t begin to explain how much you’re helping me out!

Ok, before I start asking more questions I made a few changes to my .cgi script. Now, I’m getting my “a_fail.html” page.

I changed the following parameters on my .cgi script. They were asking for url’s, not file paths.

# URL to go to if there is a problem with form input
$ErrorPage = "http://jennyw.netfirms.com/a_fail.html";

# URL to go to when form has been successfully submitted
$ThankPage = "http://jennyw.netfirms.com/a_thanks.html";

# URL to go to if a 'foreign' referer calls the script
$EvilReferer = "http://jennyw.netfirms.com/a_fail.html";

Here’s the full script again…
http://members.home.net/pie3.14/AlphaMail.txt

Here’s my url…
http://jennyw.netfirms.com

In Reply To
You wrote…
This error mostly shows when there's a problem with the file rather than with the source code.
There were two problems: First, you have to convert all your CGI-scripts to Unix format. The file you linked to was in DOS format, meaning each line was terminated by a CR/LF sequence, while lines in Unix files are only terminated with a LF character.

How can you tell that my .cgi doc was in DOS format? What did you see?

To do this conversion, you can use a good text editor (e.g. UltraEdit, use File / Convert / DOS to Unix) or the following script:

#!/bin/perl -w

undef $/;
$file = shift || 'filename.cgi';

open FILE, $file or die "cannot open $file: $!\n";
$_ = <FILE>;
close FILE;

rename $file, "$file.bak";
s/\r\n/\n/g;

open FILE, ">$file" or die "cannot open $file: $!\n";
binmode FILE;
print FILE;
close FILE;

I can’t use Notepad or Wordpad? If so, why not?
Is UltraEdit free? I’d be looking for a free program if the above two can’t be used.

In regards to the script above
Where would I place it? Is it a separate file or does it go within the .cgi script that needs changing?
Would I use this for all DOS to Unix .cgi script conversions?

I was told that all of my .cgi scripts need to be uploaded in 'ASCII' format? Is this correct?
In WSFTP there are three options: ASCII - Binary - Auto

What is Auto?

Ohh boy here I go again, I didn’t want to ask this many questions.


In Reply To
You wrote…
The second problem I discovered is that CGI files at netfirms need to be mode 700 instead of mode 755. By the time I registered at netfirms, they also wrote 700 on their page. Perhaps they're making a transition here and it'll work with 755, but if you change to 700 I think you're safe.

What is mode 700?
Mode 755 is…
Owner – Read, Write, Execute
Other – Read, Execute
Group – Read, Execute


In Reply To
We wrote…
I tried uploading the .cgi email catching script you gave me to netfirms, but it didn’t work. The page wouldn’t come up when I called it in the browser.

Well, I also tried it and it showed up. I don't know if it actually works, but at least it showed up. Are you sure it hasn't got something to do with Unix format or mode 700?

I’ll wait ‘till I get responses from previous questions before I tackle this bugger again!

In Reply To

We wrote…

http://jennyw.netfirms.com/cgi/printenv

Are you sure with this url? Shouldn't that be http://jennyw.netfirms.com/cgi-bin/printenv.cgi?

Yes, I am positive! Check out the url!

Your upload script sounds very complicated. I think I’ll stick with the basics. It’s a little over my head!
Thanks anyway Marcus!

Jenny



mhx
Enthusiast / Moderator

May 24, 2001, 11:59 PM

Post #31 of 123 (8890 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

> I changed the following parameters on my .cgi script. They were asking for url’s, not file paths.
> # URL to go to if there is a problem with form input
> $ErrorPage = "http://jennyw.netfirms.com/a_fail.html";

Have you tried if it works with

Code
$ErrorPage = "../a_fail.html";

If it does, it's easier to reuse if you change your server.

> How can you tell that my .cgi doc was in DOS format? What did you see?

Magic ;-) No, not really, both editors I'm using (Vim and UltraEdit) display the file format, which they determine from the line terminator sequence.

> I can’t use Notepad or Wordpad? If so, why not?
> Is UltraEdit free? I’d be looking for a free program if the above two can’t be used.
> In regards to the script above
> Where would I place it? Is it a separate file or does it go within the .cgi script that needs changing?
> Would I use this for all DOS to Unix .cgi script conversions?
> I was told that all of my .cgi scripts need to be uploaded in 'ASCII' format? Is this correct?
> In WSFTP there are three options: ASCII - Binary - Auto

I'll answer all this in a single paragraph :-) First, you can use any editor you want if you transfer your scripts in ASCII mode. Even if the editor generates DOS format, uploading as ASCII will automatically convert to the format needed by the server (which is Unix format for netfirms.com).
I could have given you the hint with the ASCII format, but I so rarely use it, I just forgot about it. I always transfer all my files in binary mode, so my editors both save files in Unix format. The advantage is: Unix format files will run under Windows, but DOS format won't work under Unix.
The difference between ASCII, binary and Auto can only be noticed if a Windows machine and a Unix machine are doing FTP, since they have different text format (didn't I mention this already??). In binary mode, a file is always transferred 'as is', i.e. no single byte is changed. In ASCII mode, line terminators are changed to fit for the system a file is up- or downloaded to. Perhaps also other character conversion is done. In Auto mode, the FTP-Client tries to automatically determine if a file should be transferred in ASCII or binary mode. I'm not sure which it chooses when, because I always use binary transfer.
Concerning the Editor choice, UltraEdit is not free, but IMO the second-best Windows editor and worth its money. The best editor is Vim, although many none-hardcore-programmers may not agree with me. It's the best because it's free, has simply the best syntax highlighting features (you should see Perl code with Vim!!), and is so incredibly fast to use if you work with it often enough. Unfortunately it's no fun to learn working with Vim if you only know Word or Notepad...
Concerning my script: Either forget about it (use ASCII mode) or place it anywhere on your local machine. Don't upload it, it's useless on the server. Open a command prompt, change to the directory where the script is in, and enter something like this (if you name the script dos2ux and you want to convert the cgi-file test.cgi:

Code
perl dos2ux test.cgi

The script will create a backup of the cgi-file called test.cgi.bak and the test.cgi will afterwards be in Unix format.

> What is mode 700?
> Mode 755 is
> Owner - Read, Write, Execute
> Other - Read, Execute
> Group - Read, Execute

Little excursion on Unix file flags:

Code
   user     group     all 
-----------------------
7 5 4 <- octal representation
1 1 1 1 0 1 1 0 0 <- binary representation
r w x r w x r w x
| | `--- execute permission
| `------ write permission
`-------- read permission

r w x r x r
----- ----- -----
| | `------ Everybody can read the file
| `--------------- The group may read and execute
`------------------------ The owner has full access

Now, it should be clear that mode 700 grants all right to the user and denies permission for everyone else to do anything with the file. If you would set mode 000, even the user has no permissions, but the user (and only the user) can always change the file mode.

> Yes, I am positive! Check out the url!

Ok, that was my fault. I thought the printenv script was one you've written, but it's a netfirms script that works for all accounts. I've written the printenv script on my own, so I was a bit mislead here...

> Well, I also tried it and it showed up. I don't know if it actually works, but at least it showed up. Are you sure it hasn't got something to do with Unix format or mode 700?
> I’ll wait ‘till I get responses from previous questions before I tackle this bugger again!

I just put the file into my cgi-bin directory. Test it, if you like, it's here.

> Your upload script sounds very complicated. I think I’ll stick with the basics. It’s a little over my head!

I'll send it to you as soon as I get my hands on it again ;-)

Bye,
Marcus



JennyW
journeyman

May 25, 2001, 7:16 AM

Post #32 of 123 (8884 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

 
Hi mhx - a.k.a. Marcus,


In Reply To
You wrote…

First, you can use any editor you want if you transfer your scripts in ASCII mode. Even if the editor generates DOS format, uploading as ASCII will automatically convert to the format needed by the server (which is Unix format for netfirms.com).
I could have given you the hint with the ASCII format, but I so rarely use it, I just forgot about it. I always transfer all my files in binary mode, so my editors both save files in Unix format. The advantage is: Unix format files will run under Windows, but DOS format won't work under Unix.

Ok, so what you’re saying is I don’t have to worry about text editors, as long as I upload my .cgi scripts in ASCII format then I’m ok?

The thing is I’ve uploaded my .cgi script to netfirms.com as ASCII format and I got the “a_fail.html” (error) page. However, I set my cgi-bin and .cgi scripts to chmod 755.

Do I have to set all my .cgi scripts to chmod 700?
Do I set my .cgi-bin to chmod 700 too?


In Reply To
You also wrote

Concerning my script: Either forget about it (use ASCII mode) or place it anywhere on your local machine. Don't upload it, it's useless on the server. Open a command prompt, change to the directory where the script is in, and enter something like this (if you name the script dos2ux and you want to convert the cgi-file test.cgi:
perl dos2ux test.cgi
The script will create a backup of the cgi-file called test.cgi.bak and the test.cgi will afterwards be in Unix format.

So if I do this at the command prompt then I won’t need to upload in ASCII, I can upload in binary insetad?


In Reply To
We wrote…
Yes, I am positive! Check out the url!

http:// http://jennyw.netfirms.com/cgi/printenv

Ok, that was my fault. I thought the printenv script was one you've written, but it's a netfirms script that works for all accounts. I've written the printenv script on my own, so I was a bit mislead here...

What should I do with the url above? What is its function?

In Reply To
You wrote…
Well, I also tried it and it showed up. I don't know if it actually works, but at least it showed up. Are you sure it hasn't got something to do with Unix format or mode 700?
> I’ll wait ‘till I get responses from previous questions before I tackle this bugger again!

I just put the file into my cgi-bin directory. Test it, if you like, it's here.

I noticed your script has a .cgi extension.

I read this in netfirms…

You must place all your html and image files in the 'www' directory. Only files placed in the 'www' directory can be viewed on your website. Keep all filenames in lowercase characters. Your main page should be called index.html or index.htm.The webserver first looks for index.html and if not there it looks for index.htm

Why does netfirms.com write…

Only files placed in the 'www' directory can be viewed on your website.

If only files placed in the www directory can be viewed then how are YOU able to put .cgi scripts in the cgi-bin and view them (below)?

http://mhx.netfirms.com/cgi-bin/emtest.cgi

Thanks for the great responses,
Jenny



mhx
Enthusiast / Moderator

May 25, 2001, 8:27 AM

Post #33 of 123 (8883 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

> Ok, so what you’re saying is I don’t have to worry about text editors, as long as I upload my .cgi scripts in ASCII format then I’m ok?

That's right!

> The thing is I’ve uploaded my .cgi script to netfirms.com as ASCII format and I got the a_fail.html” (error) page. However, I set my cgi-bin and .cgi scripts to chmod 755.

That's perfect, because it shows your cgi-script is actually running. If it wouldn't be running, you'd get a Server Error instead of your a_fail.html. It's not so perfect because it shows that something else is wrong...
Also, you don't have to chmod your files to 700, as they seem to work with 755.

> Do I set my .cgi-bin to chmod 700 too?

You shouldn't change the mode of your cgi-bin directory.

> So if I do this at the command prompt then I won’t need to upload in ASCII, I can upload in binary insetad?

That's right. But beware that when you're using Notepad, you won't be able to view the converted files correctly.
So I really recommend to use either ASCII upload or get a text editor supporting Unix file format.

> What should I do with the url above? What is its function?

Did you run the script? It shows which environment variables are set by the Apache server. You can access the environment variables in Perl using the %ENV hash table. But in most cases, this is not really needed. On my page, I only use it to display the Apache version.

> I noticed your script has a .cgi extension.

Well, yes. Just to show it's a CGI script... Smile

> Only files placed in the 'www' directory can be viewed on your website.
> If only files placed in the www directory can be viewed then how are YOU able to put .cgi scripts in the cgi-bin and view them (below)?
> http://mhx.netfirms.com/cgi-bin/emtest.cgi

That's because you cannot view a CGI script. You can only view its output. Whatever you print in your CGI script will be used to generate a temporary HTML file that is displayed by the webserver. This temporary file is nowhere but in the server's memory.
It's quite ok that your cannot view anything in the cgi-bin directory. If you could, everyone could steal your CGI scripts, or Amazon's, or IBM's, or ...

Hmmm, really short answers this time! Hope they help anyway...

Bye,
Marcus



JennyW
journeyman

May 25, 2001, 9:39 AM

Post #34 of 123 (8882 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee!! Friday!!

In Reply To
We wrote…
> The thing is I’ve uploaded my .cgi script to netfirms.com as ASCII format and I got the a_fail.html” (error) page. However, I set my cgi-bin and .cgi scripts to chmod 755.

That's perfect, because it shows your cgi-script is actually running. If it wouldn't be running, you'd get a Server Error instead of your a_fail.html. It's not so perfect because it shows that something else is wrong...
Also, you don't have to chmod your files to 700, as they seem to work with 755.

> Do I set my .cgi-bin to chmod 700 too?

You shouldn't change the mode of your cgi-bin directory.

I DID change the mode of my actual cgi-bin to 755. Why is this wrong?
Should I only be setting the mode for the .cgi scripts?

Should I take this line out of the .cgi script?


Code
use CGI::Carp qw(fatalsToBrowser);

The above is right under the Shebang line.

I only adjusted to the shebang line, set the variables (at beginning of doc) and I added the line listed above.

Maybe it’s my email variables? The script directed me to do the following…

# E-mail address to send intake form to (your address)
# If not using PERL 5, escape the @ thus: \@ instead of @
$YourEmail = 'themustache@hotmail.com';

I have Perl 5.004_02 so I didn’t use the \@. That’s right isn’t it?

Other than those possible problems I don’t know what could be wrong.

Here’s the .cgi script’s url…

http://members.home.net/pie3.14/AlphaMail.txt


In Reply To
We wrote…
http://jennyw.netfirms.com/cgi/printenv

> What should I do with the url above? What is its function?

Did you run the script? It shows which environment variables are set by the Apache server. You can access the environment variables in Perl using the %ENV hash table. But in most cases, this is not really needed. On my page, I only use it to display the Apache version.

I didn’t run the script. I know you said it’s not really important, but I’m curious - how would I be able to run the script?


In Reply To
We wrote…
> I noticed your script has a .cgi extension.

Well, yes. Just to show it's a CGI script...

> Only files placed in the 'www' directory can be viewed on your website.
> If only files placed in the www directory can be viewed then how are YOU able to put .cgi scripts in the cgi-bin and view them (below)?
> http://mhx.netfirms.com/cgi-bin/emtest.cgi

That's because you cannot view a CGI script. You can only view its output. Whatever you print in your CGI script will be used to generate a temporary HTML file that is displayed by the webserver. This temporary file is nowhere but in the server's memory.

I understand! So I should be able to take the email catching script you gave me http://members.home.net/pie3.14/email_catching.txt and upload it to netfirms.com and run it?

Thanks again!
Jenny



mhx
Enthusiast / Moderator

May 25, 2001, 10:45 AM

Post #35 of 123 (8880 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

> I DID change the mode of my actual cgi-bin to 755. Why is this wrong?

I didn't say it's wrong, I just meant it could be better to leave it the way it was. It guess netfirms people know why they give a certain directory certain permissions.

> Should I only be setting the mode for the .cgi scripts?

Yes.

> Should I take this line out of the .cgi script?
> use CGI::Carp qw(fatalsToBrowser);

No. Better leave it in, because it may issue useful information if there's something wrong with your script.
You can take it out if the script works fine, but you can also leave it in.

> Maybe it’s my email variables? The script directed me to do the following…
> # E-mail address to send intake form to (your address)
> # If not using PERL 5, escape the @ thus: \@ instead of @
> $YourEmail = 'themustache@hotmail.com';
> I have Perl 5.004_02 so I didn’t use the \@. That’s right isn’t it?

Yes, that's right if you only use single quotes (is this ' called single quote in english?). If you use double quotes (") you must put a backslash in front of the @.

> I didn’t run the script. I know you said it’s not really important, but I’m curious - how would I be able to run the script?

Just enter the url! Simply visit http://jennyw.netfirms.com/cgi/printenv.

> I understand! So I should be able to take the email catching script you gave me http://members.home.net/pie3.14/email_catching.txt and upload it to netfirms.com and run it?

Exactly. Just name it catchmail.cgi put it in you cgi-bin and visit http://jennyw.netfirms.com/cgi-bin/catchmail.cgi.

I've modified your script a bit, so if you could tell me what exactly the output is if you run the script now, I'll perhaps be able to tell you what's wrong.
Instead of leading you to your a_fail.html page, it will now display an error describing why it failed. I've attached the modfied file here.

Bye,
Marcus



JennyW
journeyman

May 25, 2001, 11:53 AM

Post #36 of 123 (8879 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee!

You wrote...

In Reply To
is this ' called single quote in english?

Yes it is! Wowee, I actually answered a question! lol!

You wrote…

In Reply To
I've modified your script a bit, so if you could tell me what exactly the output is if you run the script now, I'll perhaps be able to tell you what's wrong.
Instead of leading you to your a_fail.html page, it will now display an error describing why it failed. I've attached the modfied file here.

Thanks for the adjustments Marcus!
I’m unable to run the script now, but I’ll get to it very soon and let you know the results!

Out of curiosity what changes did you make to the script?
The only script adjustments I noticed were the following lines…

You added

Code
use CGI qw/:standard/;


Code
print header;

You deleted

Code
# location of Perl (above) - check your doc or ask admin

Thanks Marcus!
Jenny



mhx
Enthusiast / Moderator

May 25, 2001, 12:24 PM

Post #37 of 123 (8879 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

>> is this ' called single quote in english?
> Yes it is! Wowee, I actually answered a question! lol!

Thanks, I really wasn't sure about it...

>Out of curiosity what changes did you make to the script?

Oh, it's more than you've noticed. I mainly changed the redirection thing at the bottom of the file. Look for a line

Code
=for nobody

That's where I commented out the original code. Below is my replacement code. You'll see that I have just given the error function a string parameter which I use to give an error explanation. Instead of redirection, this explanation is printed out as HTML. Simply scroll to the end of the script and you'll see the changes.

Bye,
Marcus



mhx
Enthusiast / Moderator

May 25, 2001, 1:45 PM

Post #38 of 123 (8876 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

it's me again. As I promised, I have attached to this post my upload script. Perhaps you can just draw some ideas from it.

And, by the way, here's an example of how Vim, my favourite editor, would display a Perl script:


Code
#!/usr/bin/perl 
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use strict;

print header;

unless( param() ) # no parameters? => display form!
{
print start_html(-title => "Most Basic CGI Input Page"), start_form;
print "email, please: ", textfield(-size => 25, -name => 'Email_Address');
print submit('Submit'), end_form;
}
else # we have parameters => display results!
{
print start_html(-title => "Catching an email");
print p("Address is: ", param('Email_Address'));
}

print end_html;

Isn't that much more readable than Notepad?

Bye,
Marcus



JennyW
journeyman

May 25, 2001, 7:24 PM

Post #39 of 123 (8875 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

Ok, I tested the script you updated for me.
Here’s the url of the script (I made a new page)…

http://jennyw.netfirms.com/form_test.html

Here’s the results I received after entering an email address…

Code
CheckEmailAddressFormat: No @ !

My email address looked like this in the .cgi script…


Code
'themustache@hotmail.com'

So, I added a backslash \ in front of the @ sign and retested…

'themustache\@hotmail.com'

I received the same message…

Code
CheckEmailAddressFormat: No @ !

I changed it back – took out the backslash

Here’s the full .cgi code, including your adjustments…
http://members.home.net/pie3.14/alphamail_002.txt

Does the problem have anything to do with my <html> Form code (below)?

Code
<FORM NAME="Myform" ACTION="/cgi-bin/alphamail_002.cgi" METHOD="POST">

A few posts ago you we wrote…

In Reply To
> I changed the following parameters on my .cgi script. They were asking for url’s, not file paths.
> # URL to go to if there is a problem with form input
> $ErrorPage = "http://jennyw.netfirms.com/a_fail.html";

Have you tried if it works with
$ErrorPage = "../a_fail.html";
If it does, it's easier to reuse if you change your server

So I changed the path in .cgi script from http://jennyw.netfirms.com/a_fail.html

to…


Code
/a_fail.html

Is this correct? My settings are presently using this path.

I also tried…


Code
/cgi-bin/fail.html


This path didn’t work on the original script (WITHOUT your modifications), but it worked on the script WITH your modifications. Why is this happening?

Script WITHOUT your modifications…http://members.home.net/pie3.14/AlphaMail.txt

Script WITH your modifications…http://members.home.net/pie3.14/alphamail_002.txt

I just thought I’d let you know that I got your email catching script working.
Here’s the url…Thanks!

http://jennyw.netfirms.com/cgi-bin/mhx_email_test.cgi

Also, thanks for upload script. I’m not sure that I’ll be able to use it or if it suits my needs, but thanks!

Jenny



mhx
Enthusiast / Moderator

May 26, 2001, 12:40 AM

Post #40 of 123 (8873 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I think we're getting very close to solving your email problems Smile.

> Does the problem have anything to do with my <html> Form code (below)?

Without looking any further at the cgi script, seeing the error it suddenly came to my mind: Do we feed the right stuff into the cgi script? No, we don't! Yes, it has to do with your HTML code.
What's just missing is the text fields for Name, Email and Message. Because the email address is checked first, the script stops immediately as it doesn't discover an @ sign, because there simply is no Email field in your form.
I'm going to modify your form, so it will fit for your script. But first of all, the other things:

> 'themustache\@hotmail.com'

This is definitely wrong. Keep it without the backslash. The script doesn't mean your address, but the address of the person using the form.

> So I changed the path in .cgi script from http://jennyw.netfirms.com/a_fail.html to
> /a_fail.html
> Is this correct? My settings are presently using this path.

No, as I said, you must change it to

Code
../a_fail.html

The two dots are absolutely neccessary.

> I also tried
> /cgi-bin/fail.html
> This path didn’t work on the original script (WITHOUT your modifications), but it worked on the script WITH your modifications. Why is this happening?

The path is wrong. So the original script fails. My modified script works because I took all the a_fail.html stuff out Wink.

> Also, thanks for upload script. I’m not sure that I’ll be able to use it or if it suits my needs, but thanks!

I guess, if you're a bit more into Perl, you'll be able to use it.

But now for your HTML file modifications, here comes the step-by-step guide to success!
First, use the old cgi-script. My script with the modifications was good enough for showing me the problem, but unfortunately it fails always. (I also know why! Crazy)
Be sure you have all variables set correctly, such as the fail and thanks page.
Now, upload the following HTML code and try it. Be sure to enter something in all three fields, and be sure to give it a valid email address.

Code
<html> 
<head>
<title>Jenny's second ;-) .cgi test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#333333">

<form action="cgi-bin/alphamail_002.cgi" method="POST">
<table>
<tr>
<td><font color="#CCCC00">Your Name:</font></td>
<td><input type="TEXT" size=30 name="Name"></td>
</tr>
<tr>
<td><font color="#CCCC00">Your Email:</font></td>
<td><input type="TEXT" size=30 name="Email"></td>
</tr>
<tr>
<td><font color="#CCCC00">Your Message:</font></td>
<td><textarea name="Message" rows=12 cols=40></textarea></td>
</tr>
</table>
<input type="SUBMIT" value="Form Submission" name="SUBMIT">
</form>

<p>
<font color="#CCCC00" face="Arial, Helvetica, sans-serif" size="1">
Jenny's slightly modified Form test...
</font>
</p>
<p>
<font color="#CCCC00" face="Arial, Helvetica, sans-serif" size="1">
05_26_01
</font>
</p>

</body>
</html>

And tell about me your results, please.

Bye,
Marcus



JennyW
journeyman

May 26, 2001, 4:35 PM

Post #41 of 123 (8862 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi! Having a good weekend Marcus!

I used your <html> script with the original .cgi script and unfortunately my test was unsuccessful. I receive the FAIL page.
Here’s my page…

http://jennyw.netfirms.com/form_test_05_26_01.html

Here’s my .cgi script…

http://members.home.net/pie3.14/AlphaMail.txt

CGI script – I made the adjustments below…

Code
../a_fail.html


Code
../a_thanks.html

I even tried inserting the url’s for the “thanks”, “fail” and “EvilReferer” pages in the .cgi script, but I was still received the FAIL page.

In Reply To
What's just missing is the text fields for Name, Email and Message. Because the email address is checked first, the script stops immediately as it doesn't discover an @ sign, because there simply is no Email field in your form…
…Now, upload the following HTML code and try it. Be sure to enter something in all three fields, and be sure to give it a valid email address.

Ok, here’s what I had in the first part of my Form…

<form action="cgi-bin/alphamail.cgi" method="POST">
<table>
<tr>
<td><font color="#CCCC00">Your Name:</font></td>
<td><input type="TEXT" size=30 name="EnterName"></td>
</tr>
<tr>
<td><font color="#CCCC00">Your Email:</font></td>
<td><input type="TEXT" size=30 name="themustache@hotmail.com"></td>
</tr>
<tr>
<td><font color="#CCCC00">Your Message:</font></td>
<td><textarea name="TypeYourMessage" rows=12 cols=60></textarea></td>


What did I do wrong?

A few questions about the above…

<td><input type="TEXT" size=30 name="EnterName"></td>
and
<td><textarea name="TypeYourMessage" rows=12 cols=60></textarea></td>

Can I put spaces in the name fields above?
Example…Instead of having…

Code
TypeYourMessage

…can I write…

Code
Type Your Message

Also, I noticed that you had the ACTION of the form written like this…


Code
ACTION ="cgi-bin/alphamail_002.cgi"

Is there suppose to be a slash / in front of the cgi-bin?
(I added the slash and the script still didn’t work – I took it back out)


Code
ACTION="/cgi-bin/alphamail_002.cgi"


In Reply To
> 'themustache\@hotmail.com'

This is definitely wrong. Keep it without the backslash. The script doesn't mean your address, but the address of the person using the form.

I not clear on this. This .cgi script writes…

In Reply To
# E-mail address to send intake form to (your address)
# If not using PERL 5, escape the @ thus: \@ instead of @
$YourEmail = 'themustache@hotmail.com';

What does the address of the person using the form have to do with anything in the above?

In Reply To
No, as I said, you must change it to

Code
../a_fail.html

The two dots are absolutely neccessary.

Why are the two dots necessary?

In Reply To
../a_fail.html

Do I use this for every server I have my site on?

In Reply To
First, use the old cgi-script. My script with the modifications was good enough for showing me the problem, but unfortunately it fails always. (I also know why!)

Why does it always fail?

Thanks again!
Jenny



mhx
Enthusiast / Moderator

May 27, 2001, 1:00 AM

Post #42 of 123 (8854 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

well, before I start answering your questions: IT WORKS!
I've just uploaded my modified HTML page, three dummy pages (a_fail.html, a_evil.html, a_thanks.html). The only changes I've made had to do with uploading and testing. I've replaced your email with mine (I can't check yours...), I've added my host to the list of referers, I've added the evil referer page and I renamed the script to alphamail.cgi.
If you like, you can test it. Enter your own email address in the form and you should receive a reply immediately. I've sent a mail to myself, and received the mail as well as the reply.

> CGI script I made the adjustments below
> ../a_fail.html
> ../a_thanks.html
> I even tried inserting the url’s for the thanks, fail and EvilReferer pages in the .cgi script, but I was still received the FAIL page.

Again, if you receive the fail page, your script works and fails not because these URLs are wrong.

> What did I do wrong?

Your HTML page couldn't work, because it's simply not what I have sent to you. You changed the names of the form elements, and so the script doesn't find these elements. You've used EnterName instead of Name, themustache@hotmail.com instead of Email and TypeYourMessage instead of Message. I guess that's all that went wrong. You could do me a favor and answer another question: Why did you change nearly the only thing that could make it all fail before testing with what I've sent you?

> Can I put spaces in the name fields above?

**NO** YOU MAY NOT EVEN MODIFY THESE!!! What are you trying to do? If you want to put some default text into the input fields, that's done like this:

Code
<input type="TEXT" size=30 name="Email" value="mhx@gmx.de"> 
<textarea name="Message" rows=12 cols=60>Enter your Message here</textarea>

> ACTION ="cgi-bin/alphamail_002.cgi"
> Is there suppose to be a slash / in front of the cgi-bin?
> (I added the slash and the script still didn’t work I took it back out)
> ACTION="/cgi-bin/alphamail_002.cgi"

No, you don't need a slash. Again, your script works, the HTML form is wrong.

> The script doesn't mean your address, but the address of the person using the form.
> I not clear on this. This .cgi script writes
> # E-mail address to send intake form to (your address)
> # If not using PERL 5, escape the @ thus: \@ instead of @
> $YourEmail = 'themustache@hotmail.com';
> What does the address of the person using the form have to do with anything in the above?

My quote (The script doesn't mean your address, but the address of the person using the form.) was just out of context.
What I was trying to say: You got an error from the script telling you that there was no @ in the email address. You changed your email address in the script. But your email address isn't even checked by the script. What the script is checking is the address the user has entered in the HTML form. Since your form was wrong, the script delivered an error. Changing your email address in the script by adding a backslash (which is wrong in this place) doesn't have any effect on the error you get. I hope this is now clear. Smile

> Why are the two dots necessary?

Um, that's a bit tough to say... From the webserver's point of view, the cgi-bin directory is a subdirectory of the www directory. That's why you can access CGI scripts from HTML located in the www directory by using a link cgi-bin/whatever.cgi.
So, in exactly the same way, the www directory is a parent directory to the cgi-bin directory. And the two dots .. mean nothing but parent directory. So anytime you want to access a HTML file located in the www directory from within the cgi-bin directory, do it like this.
I hope I didn't confuse you with this...

> Do I use this for every server I have my site on?

Yes, I guess this should work for most servers.

> Why does it always fail?

Oooo, I'm sure this will confuse you, but anyway, you asked for it.
I've used the CGI module in the modified script. As soon as this module is used, it takes over the parsing of the form data, similarly to the ReadParse function in the script. Unfortunately, when this is done, there's nothing left to parse for ReadParse. And thus, the script will always fail because it never receives any data from even a valid HTML form. Nevertheless the modified script was useful, because it reminded me of the HTML form problem.

Bye,
Marcus



JennyW
journeyman

May 27, 2001, 3:11 PM

Post #43 of 123 (8838 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hey Marcus!
Well, everything works! Thank you so much. Your help is invaluable! However, this doesn’t mean I’m gonna stop bugging you!

Here’s my url if you wanna try the Form.

Jenny’s FORM

In Reply To
Your HTML page couldn't work, because it's simply not what I have sent to you. You changed the names of the form elements, and so the script doesn't find these elements. You've used EnterName instead of Name, themustache@hotmail.com instead of Email and TypeYourMessage instead of Message. I guess that's all that went wrong. You could do me a favor and answer another question: Why did you change nearly the only thing that could make it all fail before testing with what I've sent you?

I changed the NAME, EMAIL and MESSAGE fields because I misinterpreted an earlier message you wrote.

In Reply To
Now, upload the following HTML code and try it. Be sure to enter something in all three fields, and be sure to give it a valid email address.

I thought you meant enter something in the three fields (NAME, EMAIL and MESSAGE) within the FORM’s <html> code. It was a mistake totally on my part. I now understand you meant the three fields in the browser window.

In Reply To
> Can I put spaces in the name fields above?

**NO** YOU MAY NOT EVEN MODIFY THESE!!! What are you trying to do?

I totally made a mistake.

A few questions…

I don’t want the user to go to a THANK YOU page. Do I just comment out the second line below?

# URL to go to when form has been successfully submitted
$ThankPage = "../a_thanks.html";


I also don’t want an Autoresponse sent out.

Do I just comment out the following…

sub SendAutoReply {
open (MAIL,"|$MailProgram -t");
print MAIL "To: $Email\n";
print MAIL "From: $YourEmail\n";
print MAIL "Subject: $Subject\n";
print MAIL "$Header\n";
print MAIL "$Date\n\n";
print MAIL "$Subject\n\n";
print MAIL "You sent the following:\n\n";
print MAIL "==============================\n\n";
print MAIL "Name: $Name\n";
print MAIL "Email: $Email\n\n";
print MAIL "Message:\n\n";
print MAIL "$Message\n\n";
print MAIL "==============================\n\n";
print MAIL "$TailMessage\n\n";
print MAIL "Best regards,\n\n\n";
print MAIL "$Signature1\n";
print MAIL "$Signature2\n\n";
close (MAIL);
}



Thanks so much!
Jenny



mhx
Enthusiast / Moderator

May 27, 2001, 10:53 PM

Post #44 of 123 (8834 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
Well, everything works! Thank you so much. Your help is invaluable! However, this doesn’t mean I’m gonna stop bugging you!

I've just been testing your e-mailer and it worked perfectly. Smile

In Reply To
I changed the NAME, EMAIL and MESSAGE fields because I misinterpreted an earlier message you wrote.
Now, upload the following HTML code and try it. Be sure to enter something in all three fields, and be sure to give it a valid email address.
I thought you meant enter something in the three fields (NAME, EMAIL and MESSAGE) within the FORM’s <html> code. It was a mistake totally on my part. I now understand you meant the three fields in the browser window.

Oooo, now I get it!!! Sorry I was confusing you. Perhaps it's due to my low-end english...

Concerning your questions, I'm going to have a look when I'm back home. Anyway, I'm giving a rough guess here, perhaps it'll work. Wink


In Reply To
I don’t want the user to go to a THANK YOU page. Do I just comment out the second line below?

That wouldn't be a good idea, because you would end up nowhere. You've got to send the user somewhere. Simply enter the URL (can also be relative URL with '../') of the page you want the user to be sent to instead of '../a_thanks.html'.


In Reply To
I also don’t want an Autoresponse sent out.
Do I just comment out the following…

That wouldn't be a good idea either, because the script wouldn't run anymore... But it's not far from the truth! Just comment this section out, as you proposed, but additionally, look through the script for any other occurrence of SendAutoReply. There should be only one, shortly after the section where you are told not to modify anything below, as far as I can recall. Comment this line out, too, and you should no longer be sending auto-replies.

Anyway, I don't think it's good to give no feedback to the user. I guess this is uncritical here, but I personally like to have feedback on forms I filled out, even if it costs me some clicks. That's why I like amazon, they tell me that my order has been placed on their page, they send me an email that it has been placed and what I've ordered, and they send me mail when they send my stuff out, so I always know what's going on.
Personally, I'd keep the thankyou page (just redesign it a bit, it's really boring) and I'd make the autoreply optional. So a user can decide whether he wants to receive a copy of what he's sending you or not. This can be disabled by default. If you're interested in how to do this, just tell me.

Bye,
Marcus



JennyW
journeyman

May 28, 2001, 4:13 PM

Post #45 of 123 (8830 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

In Reply To
Oooo, now I get it!!! Sorry I was confusing you. Perhaps it's due to my low-end english...

No, you weren’t confusing me. I was confusing myself. You explain things better than 99 per cent of the people I’ve talked with. You also have better English than most of the people I’m around. You’re very thorough, which is great!

In Reply To
I don’t want the user to go to a THANK YOU page. Do I just comment out the second line below?

That wouldn't be a good idea, because you would end up nowhere. You've got to send the user somewhere. Simply enter the URL (can
also be relative URL with '../') of the page you want the user to be sent to instead of '../a_thanks.html'.

I don’t want the user to be sent to a thank you page. I don’t like that kind of thing. I have a great dhtml script that I’m gonna use for my forms.

If you’re interested here it is…

DHTML Form enhancement

In due time I have a few things I’d like to add to that DHTML script.


In Reply To
You've got to send the user somewhere. Simply enter the URL (can also be relative URL with '../') of the page you want the user to be sent to instead of '../a_thanks.html'.

Does the above mean that I can also enter…

../a_some_page.html ?

In Reply To
I also don’t want an Autoresponse sent out.
Do I just comment out the following…

That wouldn't be a good idea either, because the script wouldn't run anymore...

Are you pulling my leggy?

In Reply To
Personally, I'd keep the thankyou page (just redesign it a bit, it's really boring) and I'd make the autoreply optional. So a user can decide whether he wants to receive a copy of what he's sending you or not. This can be disabled by default. If you're interested in how to do this, just tell me.

Yes, that’s a great idea. I’d love to know how to make the auto-reply optional! That would totally suit the user and my needs.

Thanks so much!
Jenny



mhx
Enthusiast / Moderator

May 28, 2001, 10:59 PM

Post #46 of 123 (8822 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

In Reply To
You explain things better than 99 per cent of the people I’ve talked with. You also have better English than most of the people I’m around.

Thanks a lot, I'll give part of this back to my english teachers. Seems they did quite a good job... Wink

In Reply To
I don’t want the user to be sent to a thank you page. I don’t like that kind of thing. I have a great dhtml script that I’m gonna use for my forms.
If you’re interested here it is…
DHTML Form enhancement
In due time I have a few things I’d like to add to that DHTML script.

You mean that demo with the automatically disabling buttons? Ok, this might be a good solution!

In Reply To
Does the above mean that I can also enter…
../a_some_page.html ?

Exactly that is what it meas. You could also name it ../hello.html or even justanotherscript.cgi.

In Reply To
That wouldn't be a good idea either, because the script wouldn't run anymore...
Are you pulling my leggy?

I really wish I'd understand that. Unfortunately, my english orthography is far better than my english idioms are.

In Reply To
Yes, that’s a great idea. I’d love to know how to make the auto-reply optional! That would totally suit the user and my needs.

Ok, this means you've got to modify the form and the script. It shouldn't be a big thing, but I'm going to test it first before I start explaining it to you.

Bye,
Marcus




mhx
Enthusiast / Moderator

May 29, 2001, 2:13 PM

Post #47 of 123 (8813 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I just figured out how to implement the optional auto-reply. It's easier than I expected!
You only have to modify a single line in the alphamail.cgi script. Search the line

Code
&SendAutoReply;

(must be near line 90 in the script). I think it's commented out in your script since you didn't like the auto-reply. Replace this line by

Code
&SendAutoReply if exists $in{'WantAutoReply'};

You also have to put the whole SendAutoReply function back in in case you commented this out, too. That's everything for the cgi script.
Now, let's add the neccessary code to the HTML form. Just add the line

Code
<input type=checkbox name="WantAutoReply">Send me a copy of my mail!

anywhere you like it to appear, but inside the <form> tag. I've put it there to test it:

Code
    <tr> 
<td><font color="#CCCC00">Your Message:</font></td>
<td><textarea name="Message" rows=12 cols=40>Enter your message!</textarea></td>
</tr>
<tr>
<td></td>
<td><input type=checkbox name="WantAutoReply"><font color="#CCCC00">Send me a copy of my mail!</font></td>
</tr>

</table>
<input type="SUBMIT" value="Form Submission" name="SUBMIT">

So it will appear right below the message text box.
Yes, that's all. I was also surprised how simple it was. Smile Much fun with testing this, let me know if it works for you.

Bye,
Marcus



JennyW
journeyman

May 29, 2001, 6:19 PM

Post #48 of 123 (8811 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

Wow! That’s great! Your script adjustment worked nicely!

Here’s my page…

http://jennyw.netfirms.com/form_test_05_29_01.html

If you wanna take a look at the adjustment, here’s my .cgi script…

http://jennyw.netfirms.com/alphamail_new.txt

I have a question.
Below my email Form, I inserted a short display Form. When you press “Print msg” the word, “message” pops up.

I want this same action to take place on the email Form you kindly helped me with.

When I press “Form Submission” I want a message to display (Example: Thank You).

Do you know how I can do this? I tried adjusting the <html>, but was unsuccessful. If you’re unsure it’s definitely OK. You’ve been so helpful!


In Reply To
>That wouldn't be a good idea either, because the script wouldn't run anymore...
>>Are you pulling my leggy?

>>>I really wish I'd understand that. Unfortunately, my english orthography is far better than my english idioms are.

Regarding…
Are you pulling my leggy?

What I meant was, “Are you serious?

Thanks again and again and again!
Jenny



mhx
Enthusiast / Moderator

May 29, 2001, 10:59 PM

Post #49 of 123 (8807 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

Nice to see it works. I didn't really test it... Wink

In Reply To
Wow! That’s great! Your script adjustment worked nicely!

Here’s my page…

http://jennyw.netfirms.com/form_test_05_29_01.html

Just another question by myself: Do you use a tool for creating your HTML, like Frontpage or Dreamweaver? Or do you write it by hand, using an editor? I'm just wondering because I see all these <div>'s and really long <font> specs, which I rarely use. I prefer a good style sheet over having tons of <font> tags in the HTML, which then are also hard to keep consistent. But that's only personal interest.

In Reply To
When I press “Form Submission” I want a message to display (Example: Thank You).

Do you know how I can do this? I tried adjusting the <html>, but was unsuccessful. If you’re unsure it’s definitely OK. You’ve been so helpful!

I'd guess that's a slightly bigger problem now. The problem is, if you hit submit and thus the cgi-script is being activated, the script redirects you to some other - or even the same - page. This means the current page (the one with your forms) disappears, and is loaded again after completion of the cgi-script (if your forms page is entered where currently your thankyou page is entered in the script). Nevertheless, you information entered in that page is lost.
I now have two ideas. One is that, perhaps, the cgi-script needn't do a redirection. But I don't think this is possible, because the script must do anything, I guess. But I'll figure this out.
The other thing that comes to my mind would mean integrating your HTML form into the cgi script. This would definitely work, and you would have a lot more possibilities. But it would also mean to say goodbye to your HTML design tools, because AFAIK they don't support integration of HTML into cgi-scripts.
Well, unfortunately no one-liner this time. But I can try to get something working if you like.

Bye,
Marcus

P.S.: Thanks for the explanation. I guessed into that direction from context, but I wasn't sure...



JennyW
journeyman

May 30, 2001, 6:26 AM

Post #50 of 123 (8803 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hiee!

In Reply To
Just another question by myself: Do you use a tool for creating your HTML, like Frontpage or Dreamweaver? Or do you write it by hand, using an editor? I'm just wondering because I see all these <div>'s and really long <font> specs, which I rarely use.

Yes, I use Dreamweaver. However, I also do some basic editing myself.

In Reply To
>>When I press “Form Submission” I want a message to display (Example: Thank You).

>>Do you know how I can do this? I tried adjusting the <html>, but was unsuccessful. If you’re unsure it’s definitely OK. You’ve been so helpful!

>I'd guess that's a slightly bigger problem now. The problem is, if you hit submit and thus the cgi-script is being activated, the script redirects you to some other - or even the same - page. This means the current page (the one with your forms) disappears, and is loaded again after completion of the cgi-script (if your forms page is entered where currently your thankyou page is entered in the script). Nevertheless, you information entered in that page is lost.

Well, I’ve decided that my page IS gonna re-direct to another page (Example…Thank You page). After someone presses “Form Submission” I still want a message to pop up (on the Form page).

I’m assuming that since my page will be re-directing that I’ll be able to get this message to appear?

The following dating site has a good example of the pop-up message I’m talking about.
If you scroll to the bottom of the screen you’ll see the Form buttons (Search Current Ads) I’m talking about.
Blinddate.com


In Reply To
The other thing that comes to my mind would mean integrating your HTML form into the cgi script. This would definitely work, and you would have a lot more possibilities. But it would also mean to say goodbye to your HTML design tools, because AFAIK they don't support integration of HTML into cgi-scripts.

Well, if I ever decide to integrate my html within a .cgi document then can’t I just do all my html formatting in say, Dreamweaver and then cut and paste it into my .cgi document (Example… <<ENDHTML … ENDHTML)?

What is AFAIK?


Thanks,
Jenny


First page Previous page 1 2 3 4 5 Next page Last page  View All
 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives