-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathanswer.php
119 lines (107 loc) · 3.02 KB
/
answer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<html>
<head>
<meta charset="utf-8"/>
<title>Report</title>
<link href='http://fonts.googleapis.com/css?family=Metrophobic' rel='stylesheet' type='text/css'>
<link href="css/vpi.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
if(isset($_POST['Answer']))
{
$conn = mysql_connect("mysql5-48.90", "morphome-vpi", "r00tpassw0rd");
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$A=$_GET['a'];
$k=$_GET['k'];
$mu=$_GET['mu'];
$cooperativeness=$_POST['cooperativeness'];
$humanness=$_POST['humanness'];
$sql = "INSERT INTO answers VALUES('',now(),'$A','$k','$mu','$cooperativeness','$humanness')";
mysql_select_db('morphome-vpi');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";
mysql_close($conn);
}
else
{
?>
<div style="height:380px;width:280px;">
<h1> Report </h1>
<form id="radio-form" onsubmit="return validate();" method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="400">How cooperative was the partner?</td>
</tr>
<tr>
<td>
<input type="radio" name="cooperativeness" value="-1" style="margin-left: 50px">Very competitive
<br><input type="radio" name="cooperativeness" value="-0.5" style="margin-left: 50px">Competitive
<br><input type="radio" name="cooperativeness" value="0" style="margin-left: 50px">Neutral
<br><input type="radio" name="cooperativeness" value="0.5" style="margin-left: 50px">Cooperative
<br><input type="radio" name="cooperativeness" value="1" style="margin-left: 50px">Very Cooperative
</td>
</tr>
<td>
<tr></tr>
</td>
<tr>
<td width="400">How realistic was the interaction?<br></td>
</tr>
<tr>
<td>
<input type="radio" name="humanness" value="-1" style="margin-left: 50px">Robot like
<br><input type="radio" name="humanness" value="-0.5" style="margin-left: 50px">Slightly robot like
<br><input type="radio" name="humanness" value="0" style="margin-left: 50px">I don't know...
<br><input type="radio" name="humanness" value="0.5" style="margin-left: 50px">Slightly human like
<br><input type="radio" name="humanness" value="1" style="margin-left: 50px">Human like
</td>
</tr>
<tr>
<td width="300">
<input name="Answer" type="submit" id="Answer" value="Answer" style="margin-left: 200px">
</td>
</tr>
</table>
</form>
<?php
}
?>
</div>
<script>
function validate() {
// check cooperativeness input
var r = document.getElementsByName("cooperativeness");
var c = -1;
for(var i=0; i < r.length; i++){
if(r[i].checked) {
c = i;
}
}
if (c == -1) {
alert("Please select cooperativeness and humaness.");
return false;
}
// check humanness input
var r = document.getElementsByName("cooperativeness");
var c = -1;
for(var i=0; i < r.length; i++){
if(r[i].checked) {
c = i;
}
}
if (c == -1) {
alert("Please select cooperativeness and humaness.");
return false;
}
return true;
}
</script>
</body>
</html>