Ask an Internet Research Question

From PsychWiki - A Collaborative Psychology Wiki

Jump to: navigation, search

This page is being watched by Ravi Iyer, a php/mysql programmer/graduate student in Social Psychology, who built the technical parts of this website, in order to provide a forum for people to get help on the technical aspects of creating an internet survey in a way where the knowledge isn't lost. Simply edit this page by adding your question and Ravi promises to get back to you with an answer. Over time, we hope to accumulate a broad spectrum of questions/answers.


Contents


I want to start doing studies online, so do I need my OWN webpage for that, or can I put the study somehow on a webpage within my school’s official webpage?

This depends on a number of factors, such as the purpose and methodology of the study, the level of technical support and resources provided by your institution, as well as the policies and procedures governing the use of their resources. At some institutions there is a lot of red tape and regulation of the school's official web resources (with good reason) such that it is much easier to turn to external resources. If your study simply requires the administration of a survey or the integration of some basic media elements you could use on of many popular online survey platforms (e.g., Qualtrics or Survey Monkey).

If more advanced features are required, it is probably worthwhile to find your own hosting provider. This may seem like a daunting task, but in reality, your new hosting provider is likely to have tools guide you through the process and ease the transition. Most decent hosting providers in the $10-20/month range will provide a control panel where you can create databases, view statistics on your visitors, setup email accounts, and more. Before signing up with a webhost, ensure they provide each piece of technology that you need for your study (typically php & mysql).

You can check out this article on Lifehacker for a comparison of some of the highest rated webhosts.

How do I get a domain name and hosting?

Domain names (ie. "psychwiki.com") are rented by the year and cost from $7-30 each year. Once you have a name, you can keep it and renew it for as many years as you wish. In addition to ".com", ".net", and ".org" domain names, you can buy names associated with a country (ie. ".uk" or ".in") from specialized registrars although there are rules for this.

You can use google to find a list of domain name registrars (ie. GoDaddy or Network Solutions), but most hosting companies will also sell you a domain name when you sign up with them. They'll take care of pointing the domain name to your hosting companies nameserver if you don't want to deal with it. This may sound complex, but it's simply a matter of putting in the right answer (your hosting company will tell you the value) in the right place when you register your domain name.

How do I get subjects for my studies?

It is human nature to assume that if we build something, people will realize our effort and utilize it, but unfortunately, on the internet, it takes work to get people to find your study. There is no single answer to this question and you may have to try a number of things before you find something that works for your study, depending on the subject matter and incentives you are offering. Try http://www.psychwiki.com/wiki/Internet_Research#Recruiting_Subjects for an ongoing discussion of subject recruitment.

What about diary (or multi-wave) studies?

Dear Ravi,

We have designed a diary study and would like to collect some data online. Our participants are supposed to fill out their first batch of questionnaires online on the first day, and come back to fill out additional questionnaire in a form of diaries everyday in a 14-day period. If they missed one day, the system should generate an automatic email to remind them of participation. Is there a good way to do that? Your help will be appreciated.

What you need is a "cronjob" which is a process which runs a script automatically. You'll need to create a script/page which checks the database for users which have not filled out a questionnaire and then mails them a reminder. The php function to send a mail to someone is documented here -> http://us3.php.net/function.mail.

Then, go to the control panel of your website (should be your web address + /cpanel) and there should be an option called cron jobs. There, you can setup a daily task to run your script. The only somewhat difficult thing is getting your pathnames for php correct. You can ask your hosting company for help with this, but your command to schedule will usually be something like "/usr/lib/php -q /home/USERNAME/scriptname" where USERNAME is the username you used to log into your control panel and /usr/lib/php is the path to php that your host company gives you.

How do I password protect my website if I want to restrict access?

The long answer involves creating a .htaccess file, placing it in the directory that you want to restrict access to, and using 'htpasswd' to create a username/password. More ingormation on that is here.... http://www.javascriptkit.com/howto/htaccess3.shtml

But if your web hosting account has a control panel (most do), you can actually do that from the control panel of your account using your ftp login and password to access the control panel (usually at the URL of your website plus /cpanel). Find the "web protect directories" or "web protect" option and the instructions should be fairly self explanatory (navigate to the directory, check the protect box, and create a username/password combination to access it).

Feel free to ask more questions if you need more detail or things clarified.

Programming Script - Perl vs. PHP

I am trying to figure out what programming script to use to be able to store info for my online studies. I was recommended Perl by someone who conducts studies online, but am not convinced it is the best way to go. Is there a reason you would recommend PhP over other similar types of script?

I recommend PHP because it's easier to learn. PHP is inserted within your html code. For example, you may have a page and want to print out the current date...you would simply add <? echo date('M-d-Y'); ?> at the appropriate page in your html page, rename it with a .php extension, and assuming that your webserver is configured correctly, you've just written a php program.

In contrast, Perl requires you to learn to write standalone scripts which output html. It can be embedded like php, but it isn't specialized for that purpose. Figuring out how to get your web server to run perl programs is a bit harder too....then again, I mainly do php myself so I'm biased. But I truly believe that php is the easier language to learn and it's becoming more and more the standard. If you aren't a programmer, you probably can do anything you want easier in php.

Perl is a fine language. It supposedly is more versatile than php, which is really specialized for web applications. But if you're building a web application, you probably don't care about how versatile your programming language is anyways. Less versatile = simpler...:)


Great, that is very useful to know.

Is there a book that you would recommend for learning PhP?

I have in general found it easy to find books that talk about web design and creation, but difficult to find anything tailored for the purposes we need. Thanks for your help.

There are a couple research specific books listed here that are great.... http://www.psychwiki.com/wiki/Internet_Research#Books_on_Online_Research

but none of them teach you php...for that, I'd recommend doing online tutorials more than getting a book. Do a google search for "php tutorial or try this website...

http://www.w3schools.com/php/php_intro.asp

....but I would skip the part about installing php/mysql/apache as you really should have a web host that already has that setup for you. So getting started should be as simple as renaming your pages from .html to .php and adding the snippets in the tutorial.

Can I test my code without a web server?

Ravi, I am in the process of learning PhP and MySQL, but have not yet purchased space on a web server that supports these programs. Is there anyway to test my PhP code and MySQL database without the webserver space? I am waiting on purchasing web space because I am unsure about a domain name, but still want to develop my script in the meantime. Thanks!

Yes, you can test scripts without web server space by installing Php, Apache, and MySQL on your local computer. It can be a bit daunting at first, but it's easier than it sounds. If you type 'install php mysql apache' into google, you'll get some windows installation FAQs (ie. http://www.php-mysql-tutorial.com/install-apache-php-mysql.php) As well, there is apparently (I've never tried it) a unified installation program for windows called WAMP5, which may make the process easier (http://www.wampserver.com/en/presentation.php).

After you've installed php/mysql/apache, you need to make sure they are running as services on your computer and then you should be able to open php files using a web browser's file->open command to open local files, just like you're opening a word document.

Good luck and let me know if you need further assistance.

-Ravi

Where can I get help with my PhP script?

Ravi, I have been learning PhP and MySQL over the past few days. Thanks for the advice in favor of PhP over Perl, it really is much more user friendly! With that being said, I am having problems with my first set of PhP code but I can't figure out what is wrong. I have posted my script to a few tech sites with the hopes that someone would help, but nothing so far. Do you have any suggestion as to how I can figure out what is wrong? Thanks so much for your help!


Posting to tech sites is a good start. The error message you get is usually pretty informative. If you want to post the piece of code here and let me know the error message, I'll give you some ideas about what I might to do find the problem.

Great! Thanks so much for your help. I posted my question on a tech site and got the problem fixed. Thanks!


Does anyone have a piece of PHP code that randomizes to conditions?

What do you want the results of the randomization to be? The basics are....

$condition = rand(1,5); // it will give a random number from 1 to 5

if ($condition==1)  // do something different in each condition...
{
}
elseif ($condition==2)
{
 }
 elseif ($condition==3)
{
}
......

How do I use the randomization code to send it to another php page

if ($condition==1)  // do something different in each condition...
{
echo '<meta http-equiv="refresh"
content="2;url=http://www.site.com/version1.php" />';
}
 elseif ($condition==2)
 {
 {
 echo '<meta http-equiv="refresh"
 content="2;url=http://www.site.com/version2.php" />';
  }
  elseif ($condition==3)
  {
 {
 echo '<meta http-equiv="refresh"
 content="2;url=http://www.site.com/version3.php" />';
  }

the internet gods don't appear to appreciate the code.

I got this error: 
>
> Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in
> /home/psychexperiment/www/www/groupsurvey/random2.php on line 7
>
>
> Here's my code:
>
> <?php
> $condition=rand(1,6);
>  if ($condition==1)  // do something different in each condition...
> {
> echo '<meta http-equiv="refresh"
> content="2;url=http://www.psychexperiment.net/groupsurvey/version1.php"
/>';
> }  elseif ($condition==2)  { { echo '<meta http-equiv="refresh"
> content="2;url=http://www.psychexperiment.net/groupsurvey/version2.php"
/>';
> }  elseif ($condition==3)  { { echo '<meta http-equiv="refresh"
> content="2;url=http://www.psychexperiment.net/groupsurvey/version3.php"
/>';
> }

The error is generally pretty instructive...so if you go to line 7, you should be able to see what the issue is....to me, it looks like you've doubled up your brackets (ie. "{ {" instead of "{"





◄ Back to Collecting Data page

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox