Forum Moderators: coopster & phranque

Message Too Old, No Replies

"Tell a Friend" script question

         

Matrixster

9:21 pm on Apr 20, 2005 (gmt 0)

10+ Year Member



I have the script for the "Tell a Friend" I would like to use
(script located here [webmasterworld.com...] )

But what do I actually do with this script?
(Sorry newbie here)

wruppert

3:39 am on Apr 21, 2005 (gmt 0)

10+ Year Member



You put the script in a directory where your server expects to find scripts. That is often named cgi-bin. The server must be able to read and execute the script.

You create a link to the script somewhere on your site. Something like "http://www.yoursite.com/cgi-bin/tellfriend.cgi".

When someone clicks on the link, it displays the form. When someone hits the send button on that form, the script sends an email.

That is very general, you may want to ask more specific questions.

Matrixster

3:46 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



OK, I understand the script gets put in the cgi_bin. To be more specific:
Lets say I just highlighted and copied all the text for the "tell a friend" script.....

Where do I put it? What do I do with it? Do I open up Frontpage and paste it? What do I save it as, etc.

Thanks again

rocknbil

3:58 pm on Apr 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good grief whatever you do don't put it into Front Page. :-)

If you have nothing else, use Notepad.

Save the file with a .cgi or .pl extension. Most servers support both, but sometimes it's only one or the other.

If your server is a Windows server, you'll have to ask your host where you should deposit executable scripts, or have them set the permissions on a directory to scripts and executables. It's the Microsoft Way.

If your server is Linux/Unix, you can set the permissions to executable yourself, 755. If you use WS_FTP to upload the file, this can be done by right-clicking the file after upload, select CHMOD, and X all three of the bottom row of checkboxes. Alternatively you can SSH in and do this via command line, but it's not likely you'll have the means.

In either case, upload the file in ASCII mode. This is very important; binary mode will cause some wierdness in the end-of-line characters and it will probably not run.

There is really much more to this - you're likely to get an internal server error the first 10 or 20 tries, and it can be any one of a thousand things. I suggest:

1. Google for ActiveState Perl, download it to your LOCAL computer and install perl onto your system.

2. Open a DOS window (Start->Run-> type "command" on win98, or "cmd" on XP, press enter) and navigate to the directory where your script is

cd C:\folder\path_to\script\location

then run the script locally on your computer to make sure it is error free

perl scriptname.pl (press enter)

Perl is excellent about telling you exactly where your errors are.

3. Once you have the script running locally without error, it eliminates the possibility of anything inherently wrong with it. Upload it and see what happens.

Lots of perl tutorials out there, you may want to predicate your venture with a simple "hello world" script to get the hang. :-)

wruppert

4:01 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



Copy and paste the script to a simple text file, using a text editor. You can use Notepad, if nothing else.

Then you have to get that text file onto into your cgi-bin directory on your server, wherever that may be.

If I were doing it, I would FTP it up from my local machine to my host provider's machine. I would then shell in to set the priviledges, or use the host provider's web-based file manipulation tool for that.

Matrixster

4:37 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



Thanks for the help

Matrixster

8:59 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



One final clarification....
So lets say the webpage for this is tellafriend.htm
This web page will contain a form with (enter your friends name, enter your friends email, enter your name, etc) and the results will point to that custom script in cgi_bin?

wruppert

2:57 am on Apr 22, 2005 (gmt 0)

10+ Year Member



Well, not exactly. The script (named tell-a-friend.cgi in the cited posting) has the form built into it. You would place a link to tell-a-friend.cgi on your home page or somewhere - something like "Click here to tell a friend" where "here" is a link to tell-a-friend.cgi.

The script detects (due to the lack of an "action" param) that it is being called the first time, so it displays the form. Then, the user fills in the form and hits send - the script detects that because action is now "send" and it then sends the email.

HughMungus

3:24 am on Apr 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Make sure you add a part that will let them stop receiving those kinds of emails or you're opening yourself up to people who abuse it and/or report you for spam.