PEEP

Programming Economic Experiments with Php/mysql

with contributions by:
Joep Sonnemans
Lucas Molleman
Boris van Leeuwen
Jona Linde
Roel van Veldhuizen
Jeroen van de Ven

How CREED has organized the lab to run php/mysql experiments

The server computer has XAMPP installed. In the htdocs directory is a file "beginexp.html" and each experiment has its own subdirectory.
All the computers in the lab have firefox installed with the extension "kiosk". This extension makes firefox fullscreen and blocks some keys. Firefox goes to this homepage: "beginexp.html". This page looks for a cookie with the code of the table in the lab (A02, C04, etc). If the cookie is not on the computer the user is ask for the table code and a cookie is placed on that computer. This file redirects to the login page of the current experiment.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
 <META Http-Equiv="Cache-Control" Content="no-cache">
 <META Http-Equiv="Pragma" Content="no-cache">
 <META Http-Equiv="Expires" Content="0"> 
<script type="text/javascript">
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function checkCookie()
{
username=getCookie('username');
if (username!=null && username!="")
  {
  }
  else 
  {
  username=prompt('Please enter tablenumber:',"");
  if (username!=null && username!="")
    {
    setCookie('username',username,365);
    }
  }
// da onderwijs nederlands 
// FILL IN THE IP_ADDRESS OF YOUR SERVER
window.location = "http://145.18.178.158/da/beginauto.php?table="+username;
}
</script>
 </HEAD>
 <body onLoad="checkCookie()">
  refers to present experiment...
 </BODY>
</HTML>

This is a very efficient setup. When you have programmed your experiment, you make a directory in htdocs where you put your php-files and in phpmyadmin you import your database. You than only have to change the redirection line (window.location = ) in "beginexp.html" and all computers who open firefox will automatically go to your pages. In the first page of your program (login of subject) you can use $_REQUEST['table'] to get the table code of the subject.