How to Conduct Behavioral Research over the Internet: A Beginner's Guide to HTML and CGI/Perl

Internet resource for the book by R. Chris Fraley, published by Guilford Press

Chapter overviews and demonstrations
Learn more about the topics covered by the book and see live demonstrations of the exercises

Download the HTML, CGI/Perl, and image files used in the book

Read answers to frequently asked questions about conducting research online

Order the book
Order a copy of the book via the Guilford Press

Resources and links
Links to programs that may be of interest to online researchers

Home page
Overview of the book



Frequently Asked Questions
Read answers to frequently asked questions about the book and about conducting research online

Q. Is this book only for psychologists?
Although this book was written with a focus on applications to psychological science, the techniques discussed in this book are relevant to anyone working in the behavioral or social sciences, including (but not limited to) anthropology, sociology, political science, and marketing.

Q. Do I need my own web server in order to conduct research online?
No. In the book I show you how to acquire access to a server by using a professional web hosting service. This approach is very easy and, if you're willing to allow the service to place ads on your web page, you can obtain the service for free. (For a trivial fee you can have the ads removed.) In the book I also explain how to setup a personal web server for those readers who are more adventurous.

Q. I am having trouble downloading and naming the image files. Specifically, my computer is renaming the files with an *.jpeg extension instead of the *.jpg extension.
For some reason, Windows XP appears to rename the extension of the files that you download without warning you first. For example, if you download a file called "image.jpg" from the web, Windows XP will rename the file "image.jpeg" without telling you. I don't know the best solution to this inconvenience, but you may try downloading the file and, once it has been downloaded, rename the file extension manually.

Q. What is the solution to the "challenge" presented at the very end of Chapter 7?
At the end of chapter 7 I ask you to write a program that will process and save the data for a questionnaire in which a subset of items is randomly presented from a larger bank of items. I claimed that the solution was fairly simple, but, truth be told, it took me a bit longer to solve it than I had anticipated. I've posted below links to the code for two scripts that solve the problem. The first script,, is responsible for presenting five randomly selected self-esteem items from a bank of ten items. The second script,, calculates the user's self-esteem score and saves it to a text file. You can see a demonstration by clicking here: demonstration.

Q. My data/text files are not being created when the data are purportedly being saved to the server. My text data files are not being read or processed correctly. (UPDATED AUGUST 24, 2011)
Netfirms has changed something in the way their directories are organized. As such, some of the code used in the book is no longer applicable. I have updated the copy-and-pastable code that is available via this website in a way that will solve the problem. If you're referring to the book, you'll need to be mindful of those changes.

In short, to fix the problem, simply replace any command that contains the expression $ENV{'DOCUMENT_ROOT'}/www/ with $ENV{'DOCUMENT_ROOT'}/. Example:

Old code:
open(INFO, ">>$ENV{'DOCUMENT_ROOT'}/www/data/moodexample2.txt");

New code:
open(INFO, ">>$ENV{'DOCUMENT_ROOT'}/data/moodexample2.txt");

I should also note that in 2006 I made an update here that recommended using $ENV{'DOCUMENT_ROOT_OLD'} in place of $ENV{'DOCUMENT_ROOT'}. That is no longer advisable in given the 2011 restructuring that Netfirms underwent.

R. Chris Fraley |