Functie gemaakt in config.php, call in result.php "Cannot redeclare ... "
1. ga met functies werken. alle bestanden die je gaat includen mogen enkel uit functies bestaan.
2. zet je includes helemaal bovenin je code.
3. geen IF(..) { .. )
maar
4. bovenin je programma, en als laatste onderin je output.
Frank Nietbelangrijk op 18/11/2013 18:29:02:
Laat ik het zo zeggen Kevin - en ik lach je niet uit - dat je code toch wel erg chaotisch overkomt.
Waar is dit ingodsnaam goed voor?
Waar is dit ingodsnaam goed voor?
Dat gebruik ik in de "query maker" waar de gebruiker filters kan instellen (geslacht, Haarkleur, Religie, etc. En alles waar hijzij niet op wil filteren, klikt ie "I dont mind" aan. Oftewel: dat hoeft niet in de query te komen.
Frank Nietbelangrijk op 18/11/2013 22:38:24:
Kevin een paar tips als je die wilt horen:
1. ga met functies werken. alle bestanden die je gaat includen mogen enkel uit functies bestaan.
2. zet je includes helemaal bovenin je code.
3. geen IF(..) { .. )
maar
4. bovenin je programma, en als laatste onderin je output.
1. ga met functies werken. alle bestanden die je gaat includen mogen enkel uit functies bestaan.
2. zet je includes helemaal bovenin je code.
3. geen IF(..) { .. )
maar
4. bovenin je programma, en als laatste onderin je output.
1. Behalve het wachtwoord van de SQL database enzo, doe ik dat ook. Of mag die variabele ook niet?
2. Doe ik, zelfs boven Session_start. Met uitzondering van menu.php, want als ik een header activeer, moet ik niet eerst iets geprint hebben...
3. Snap ik helemaal, maar voor kleine stukjes code vind ik dit veel opgeruimder.
4. uhh... As in: eerst alles PHP'en, en daarna pas de HTML? VOlgens mij doe ik dat ook.
Zal trouwens even de huidige versie van match en result posten:
Of kijk voor jezelf: dating.url.ph
Code (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?php
include_once('config.php');
session_start();
IF (!isset($_SESSION['username']))
{ header('Location: '. $homepage); }
$con = mysql_connect($SQLhost, $SQLuser, $SQLpass) or die('Could not connect: ' . mysql_error());
mysql_select_db($SQLdb, $con) or die('Could not find database: ' . mysql_error()) ;
$background = mysql_result ( mysql_query ("SELECT Background FROM PROFIEL WHERE Username = '".$_SESSION['username']."' "), 0);
$_SESSION['query'] = "";
// controle voor invoer. If oke -> header result.php else errors maken
if ($_POST['controle'] == "TRUE") {
if(
($_POST['gender'] == "")
OR ($_POST['province'] == "Province")
OR ($_POST['hair'] == "Hair Color")
OR ($_POST['eye'] == "Eye Color")
OR ($_POST['skin'] == "Skin Color")
OR ($_POST['religion'] == "Religion")
OR ($_POST['education'] == "Education")
OR ($_POST['children'] == "Children")
OR ($_POST['childwish'] == "Childwish")
OR ($_POST['smoke'] == "")
OR ( ( ($_POST['agemin'] == "Age") OR ($_POST['agemax'] == "Age") )
AND ( $_POST['age'] != "<>" ) )
) { $error=1; $error_head="<b>!! ERROR !!</b>"; }
if ($error) {
if ($_POST['gender'] == "") { $error_gender = "You need to choose which <u>Gender</u> you want to sort on!"; }
if ($_POST['province'] == "Province") { $error_province = "You need to choose which <u>Province</u> you want to sort on!"; }
if ($_POST['hair'] == "Hair Color") { $error_hair = "You need to choose which <u>Hair Color</u> you want to sort on!"; }
if ($_POST['eye'] == "Eye Color") { $error_eye = "You need to choose which <u>Eye Color</u> you want to sort on!"; }
if ($_POST['skin'] == "Skin Color") { $error_skin = "You need to choose which <u>Skin Color</u> you want to sort on!"; }
if ($_POST['religion'] == "Religion") { $error_religion = "You need to choose which <u>Religion</u> you want to sort on!"; }
if ($_POST['education'] == "Education") { $error_education = "You need to choose which <u>Education</u> you want to sort on!"; }
if ($_POST['children'] == -1) { $error_children = "You need to choose how many <u>Children</u> you want to sort on!"; }
if ($_POST['childwish'] == -1) { $error_childwish = "You need to choose which <u>Childwish</u> you want to sort on!"; }
if ($_POST['smoke'] == "") { $error_smoke = "You need to choose whether <u>Smoking</u> is allowed!"; }
if (($_POST['agemin'] == "Age") && ($_POST['age'] != "<>" )) { $error_age = "You need to choose which <u>Age</u> you want to sort on!"; }
if (($_POST['agemax'] == "Age") && ($_POST['age'] != "<>" )) { $error_age = "You need to choose which <u>Age</u> you want to sort on!"; }
} else {
$sql_match=("SELECT * FROM USER WHERE Username <> '".$_SESSION['username']."' ");
if ($_POST['gender'] != "<>") { $sql_match .= "AND Geslacht = '".$_POST['gender']."' "; }
if ($_POST['province'] != "<>") { $sql_match .= "AND Provincie = '".$_POST['province']."' "; }
if ($_POST['hair'] != "<>") { $sql_match .= "AND Haarkleur = '".$_POST['hair']."' "; }
if ($_POST['eye'] != "<>") { $sql_match .= "AND Oogkleur = '".$_POST['eye']."' "; }
if ($_POST['skin'] != "<>") { $sql_match .= "AND Huidskleur = '".$_POST['skin']."' "; }
if ($_POST['religion'] != "<>") { $sql_match .= "AND Religie = '".$_POST['religion']."' "; }
if ($_POST['education'] != "<>"){ $sql_match .= "AND Opleiding = '".$_POST['education']."' "; }
if ($_POST['children'] != "<>") { $sql_match .= "AND Kinderen ".$_POST['chorder'] . " '" . $_POST['children']."' "; }
if ($_POST['childwish'] != "<>"){ $sql_match .= "AND Kinderwens ".$_POST['cworder'] . " '" . $_POST['childwish']."' "; }
if ($_POST['smoke'] != "<>") { $sql_match .= "AND Roken = '".$_POST['smoke']."' "; }
if ($_POST['age'] != "<>") { $sql_match .= "AND Jaar <= ".( date("Y") - $_POST['agemin'] )." AND (
(Maand = ".date("m")." AND Dag <= ".date("d").") OR (Maand < ".date("m")." ) )
AND ( ( Jaar >= ". (date("Y") - $_POST['agemax']) .") OR
( Jaar >= ". (date("Y") - $_POST['agemax'] - 1) ." AND (
( Maand > ". date("m") ." ) OR ( Maand = ".date("m")." AND Dag > ".date("d") ." )
) ) ) " ; }
$_SESSION['query'] = $sql_match;
header("Location: result.php");
} } ?>
<html>
<head>
<title>Matching - <?php echo $_SESSION['username']; ?> </title>
<link rel="icon" type="image/ico" href="favicon.ico"> </link>
</head>
<body bgcolor="<?php echo $background; ?>">
<?php include('menu.php'); ?>
<hr>
<center><big><big><b>Matching</b></big></big></center>
<b>On which attributes do you wish to select?</b>
<br><font color="#FF0000"><?php echo $error_head; ?></font> </br>
<form action="" method="post">
<input type="hidden" name="controle" value="TRUE">
<table>
<tr> <td width=120> Gender: </td>
<td width=230>
<input type="radio" name="gender" value="Male" <?php if ($_POST['gender'] == "Male" ) { echo 'checked'; } ?>>Male
<input type="radio" name="gender" value="Female" <?php if ($_POST['gender'] == "Female" ) { echo 'checked'; } ?>>Female
<input type="radio" name="gender" value="<>" <?php if ($_POST['gender'] == "<>" ) { echo 'checked'; } ?>>Both
</td> <td width=10></td> <td> <font color="#F0000"><?php echo $error_gender; ?></font></td></tr>
<tr><td >Province: </td>
<td> <?php
$province = array("Province", "Drenthe", "Flevoland", "Friesland", "Gelderland", "Groningen", "Limburg",
"Noord-Braband", "Noord-Holland", "Overijssel", "Utrecht", "Zeeland", "Zuid-Holland");
echo '<select name="province">';
for($p=0; $p<13; $p++){
if($province[$p] == $_POST["province"] ){$selected = 'selected="selected"';}else{$selected = '';}
echo '<option value="'.$province[$p].'" '.$selected.'>'.$province[$p].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="province" value="<>" <?php if ($_POST['province'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_province; ?> </td></tr>
<tr><td>Hair Color: </td>
<td> <?php
$hair= array("Hair Color", "White", "Light Blonde", "Blonde", "Light Brown", "Brown", "Grey", "Black", "Light Red", "Red", "Other");
echo '<select name="hair">';
for($h=0; $h<11; $h++){
if($hair[$h] == $_POST["hair"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$hair[$h].'" '.$selected. '>'.$hair[$h].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="hair" value="<>" <?php if ($_POST['hair'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_hair; ?> </td></tr>
<tr><td>Eye Color: </td>
<td> <?php
$eye = array("Eye Color", "Blue", "Blue-Green", "Green", "Brown");
echo '<select name="eye">';
for($e=0; $e<5; $e++){
if($eye[$e] == $_POST["eye"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$eye[$e].'" '.$selected. '>'.$eye[$e].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="eye" value="<>" <?php if ($_POST['eye'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_eye; ?> </td></tr>
<tr><td>Skin Color: </td>
<td> <?php
$skin = array("Skin Color", "White", "Lightly Tinted", "Medium Tinted", "Heavily Tinted", "Brown", "Black");
echo '<select name="skin">';
for($s=0; $s<7; $s++){
if($skin[$s] == $_POST["skin"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$skin[$s].'" '.$selected. '>'.$skin[$s].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="skin" value="<>" <?php if ($_POST['skin'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_skin; ?> </td></tr>
<tr><td>Religion: </td>
<td> <?php
$religion = array("Religion", "Cristian", "Catholic", "Reformed", "Protestant", "Moslim", "Boeddhism", "Hindoeism", "Jewish", "Other", "Atheist");
echo '<select name="religion">';
for($r=0; $r<11; $r++){
if($religion[$r] == $_POST["religion"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$religion[$r].'" '.$selected. '>'.$religion[$r].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="religion" value="<>" <?php if ($_POST['religion'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_religion; ?> </td></tr>
<tr><td>Education: </td>
<td> <?php
$education = array("Education", "VMBO", "HAVO", "VWO", "Grammar School", "Vocational", "College", "University");
echo '<select name="education">';
for($ed=0; $ed<8; $ed++){
if($education[$ed] == $_POST["education"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$education[$ed].'" '.$selected. '>'.$education[$ed].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="education" value="<>" <?php if ($_POST['education'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_education; ?> </td></tr>
<tr><td>Children: </td>
<td> <?php
$order = array("<=", "At most:", "=", "Exactly:", ">=", "At least");
$children= array("Children", "0", "1", "2", "3", "4", "5 or more");
echo '<select name="chorder">';
for ($cho=0; $cho<6; $cho+=2) {
if ($order[$cho] == $_POST["chorder"]) {$selected='selected="selected"'; } else {$selected=''; }
echo '<option value="'. $order[$cho] . '" '. $selected . '>' . $order[$cho+1].'</option>'; }
echo '</select>';
echo '<select name="children">';
for($ch=0; $ch<7; $ch++){
if($children[$ch] == $_POST["children"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'. ($ch-1) .'" '.$selected. '>'.$children[$ch].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="children" value="<>" <?php if ($_POST['children'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_children; ?> </td></tr>
<tr><td>Childwish: </td>
<td> <?php
$childwish= array("Childwish", "0", "1", "2", "3", "4", "5 or more");
echo '<select name="cworder">';
for ($cwo=0; $cwo<6; $cwo+=2) {
if ($order[$cwo] == $_POST["cworder"]) {$selected='selected="selected"'; } else {$selected=''; }
echo '<option value="'. $order[$cwo] . '" '.$selected. '>' . $order[$cwo+1].'</option>'; }
echo '</select>';
echo '<select name="childwish">';
for($cw=0; $cw<7; $cw++){
if($childwish[$cw] == $_POST["childwish"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'. ($cw-1) .'" '.$selected. '>'.$childwish[$cw].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="childwish" value="<>" <?php if ($_POST['childwish'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_childwish; ?> </td></tr>
</table><table>
<tr><td width=120>Smoking: </td>
<td><input type="radio" name="smoke" value="yes" <?php if ($_POST['smoke'] == "yes" ) { echo 'checked'; } ?>>Allowed to smoke
<input type="radio" name="smoke" value="no" <?php if ($_POST['smoke'] == "no" ) { echo 'checked'; } ?>><b>Not</b> allowed to smoke
<input type="radio" name="smoke" value="<>" <?php if ($_POST['smoke'] == "<>" ) { echo 'checked'; } ?>>I don't mind
</td width=10><td></td> <td><font color="#FF0000"> <?php echo $error_smoke; ?> </td></tr>
<tr><td>Ages: </td>
<td>Between <?php
$agemin = array("Age", "18", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75");
echo '<select name="agemin">';
for($a1=0; $a1<13; $a1++){
if($agemin[$a1] == $_POST["agemin"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$agemin[$a1].'" '.$selected. '>'.$agemin[$a1].'</option>'; }
echo '</select>'; ?>
and
<?php
$agemax = array("Age", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80");
echo '<select name="agemax">';
for($a2=0; $a2<13; $a2++){
if($agemax[$a2] == $_POST["agemax"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$agemax[$a2].'" '.$selected. '>'.$agemax[$a2].'</option>'; }
echo '</select>'; ?>
years old.
<input type="checkbox" name="age" value="<>" <?php if ($_POST['age'] == "<>" ) { echo 'checked'; } ?> >I don't mind </td>
</td> <td></td> <td><font color="#FF0000"><?php echo $error_age; ?> </td></tr>
</table><br>
<input type="submit" value="Match!"></form>
<form name="reset" method="post" action="<?php echo ($_SERVER["PHP_SELF"]);?>">
<input type="submit" value="Reset">
</form>
<hr>
<form action="profile.php?u=<?php echo $_SESSION['username']; ?>" method="post">
<input type="submit" value="Go to my own profile!"></form>
</body>
</html>
include_once('config.php');
session_start();
IF (!isset($_SESSION['username']))
{ header('Location: '. $homepage); }
$con = mysql_connect($SQLhost, $SQLuser, $SQLpass) or die('Could not connect: ' . mysql_error());
mysql_select_db($SQLdb, $con) or die('Could not find database: ' . mysql_error()) ;
$background = mysql_result ( mysql_query ("SELECT Background FROM PROFIEL WHERE Username = '".$_SESSION['username']."' "), 0);
$_SESSION['query'] = "";
// controle voor invoer. If oke -> header result.php else errors maken
if ($_POST['controle'] == "TRUE") {
if(
($_POST['gender'] == "")
OR ($_POST['province'] == "Province")
OR ($_POST['hair'] == "Hair Color")
OR ($_POST['eye'] == "Eye Color")
OR ($_POST['skin'] == "Skin Color")
OR ($_POST['religion'] == "Religion")
OR ($_POST['education'] == "Education")
OR ($_POST['children'] == "Children")
OR ($_POST['childwish'] == "Childwish")
OR ($_POST['smoke'] == "")
OR ( ( ($_POST['agemin'] == "Age") OR ($_POST['agemax'] == "Age") )
AND ( $_POST['age'] != "<>" ) )
) { $error=1; $error_head="<b>!! ERROR !!</b>"; }
if ($error) {
if ($_POST['gender'] == "") { $error_gender = "You need to choose which <u>Gender</u> you want to sort on!"; }
if ($_POST['province'] == "Province") { $error_province = "You need to choose which <u>Province</u> you want to sort on!"; }
if ($_POST['hair'] == "Hair Color") { $error_hair = "You need to choose which <u>Hair Color</u> you want to sort on!"; }
if ($_POST['eye'] == "Eye Color") { $error_eye = "You need to choose which <u>Eye Color</u> you want to sort on!"; }
if ($_POST['skin'] == "Skin Color") { $error_skin = "You need to choose which <u>Skin Color</u> you want to sort on!"; }
if ($_POST['religion'] == "Religion") { $error_religion = "You need to choose which <u>Religion</u> you want to sort on!"; }
if ($_POST['education'] == "Education") { $error_education = "You need to choose which <u>Education</u> you want to sort on!"; }
if ($_POST['children'] == -1) { $error_children = "You need to choose how many <u>Children</u> you want to sort on!"; }
if ($_POST['childwish'] == -1) { $error_childwish = "You need to choose which <u>Childwish</u> you want to sort on!"; }
if ($_POST['smoke'] == "") { $error_smoke = "You need to choose whether <u>Smoking</u> is allowed!"; }
if (($_POST['agemin'] == "Age") && ($_POST['age'] != "<>" )) { $error_age = "You need to choose which <u>Age</u> you want to sort on!"; }
if (($_POST['agemax'] == "Age") && ($_POST['age'] != "<>" )) { $error_age = "You need to choose which <u>Age</u> you want to sort on!"; }
} else {
$sql_match=("SELECT * FROM USER WHERE Username <> '".$_SESSION['username']."' ");
if ($_POST['gender'] != "<>") { $sql_match .= "AND Geslacht = '".$_POST['gender']."' "; }
if ($_POST['province'] != "<>") { $sql_match .= "AND Provincie = '".$_POST['province']."' "; }
if ($_POST['hair'] != "<>") { $sql_match .= "AND Haarkleur = '".$_POST['hair']."' "; }
if ($_POST['eye'] != "<>") { $sql_match .= "AND Oogkleur = '".$_POST['eye']."' "; }
if ($_POST['skin'] != "<>") { $sql_match .= "AND Huidskleur = '".$_POST['skin']."' "; }
if ($_POST['religion'] != "<>") { $sql_match .= "AND Religie = '".$_POST['religion']."' "; }
if ($_POST['education'] != "<>"){ $sql_match .= "AND Opleiding = '".$_POST['education']."' "; }
if ($_POST['children'] != "<>") { $sql_match .= "AND Kinderen ".$_POST['chorder'] . " '" . $_POST['children']."' "; }
if ($_POST['childwish'] != "<>"){ $sql_match .= "AND Kinderwens ".$_POST['cworder'] . " '" . $_POST['childwish']."' "; }
if ($_POST['smoke'] != "<>") { $sql_match .= "AND Roken = '".$_POST['smoke']."' "; }
if ($_POST['age'] != "<>") { $sql_match .= "AND Jaar <= ".( date("Y") - $_POST['agemin'] )." AND (
(Maand = ".date("m")." AND Dag <= ".date("d").") OR (Maand < ".date("m")." ) )
AND ( ( Jaar >= ". (date("Y") - $_POST['agemax']) .") OR
( Jaar >= ". (date("Y") - $_POST['agemax'] - 1) ." AND (
( Maand > ". date("m") ." ) OR ( Maand = ".date("m")." AND Dag > ".date("d") ." )
) ) ) " ; }
$_SESSION['query'] = $sql_match;
header("Location: result.php");
} } ?>
<html>
<head>
<title>Matching - <?php echo $_SESSION['username']; ?> </title>
<link rel="icon" type="image/ico" href="favicon.ico"> </link>
</head>
<body bgcolor="<?php echo $background; ?>">
<?php include('menu.php'); ?>
<hr>
<center><big><big><b>Matching</b></big></big></center>
<b>On which attributes do you wish to select?</b>
<br><font color="#FF0000"><?php echo $error_head; ?></font> </br>
<form action="" method="post">
<input type="hidden" name="controle" value="TRUE">
<table>
<tr> <td width=120> Gender: </td>
<td width=230>
<input type="radio" name="gender" value="Male" <?php if ($_POST['gender'] == "Male" ) { echo 'checked'; } ?>>Male
<input type="radio" name="gender" value="Female" <?php if ($_POST['gender'] == "Female" ) { echo 'checked'; } ?>>Female
<input type="radio" name="gender" value="<>" <?php if ($_POST['gender'] == "<>" ) { echo 'checked'; } ?>>Both
</td> <td width=10></td> <td> <font color="#F0000"><?php echo $error_gender; ?></font></td></tr>
<tr><td >Province: </td>
<td> <?php
$province = array("Province", "Drenthe", "Flevoland", "Friesland", "Gelderland", "Groningen", "Limburg",
"Noord-Braband", "Noord-Holland", "Overijssel", "Utrecht", "Zeeland", "Zuid-Holland");
echo '<select name="province">';
for($p=0; $p<13; $p++){
if($province[$p] == $_POST["province"] ){$selected = 'selected="selected"';}else{$selected = '';}
echo '<option value="'.$province[$p].'" '.$selected.'>'.$province[$p].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="province" value="<>" <?php if ($_POST['province'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_province; ?> </td></tr>
<tr><td>Hair Color: </td>
<td> <?php
$hair= array("Hair Color", "White", "Light Blonde", "Blonde", "Light Brown", "Brown", "Grey", "Black", "Light Red", "Red", "Other");
echo '<select name="hair">';
for($h=0; $h<11; $h++){
if($hair[$h] == $_POST["hair"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$hair[$h].'" '.$selected. '>'.$hair[$h].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="hair" value="<>" <?php if ($_POST['hair'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_hair; ?> </td></tr>
<tr><td>Eye Color: </td>
<td> <?php
$eye = array("Eye Color", "Blue", "Blue-Green", "Green", "Brown");
echo '<select name="eye">';
for($e=0; $e<5; $e++){
if($eye[$e] == $_POST["eye"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$eye[$e].'" '.$selected. '>'.$eye[$e].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="eye" value="<>" <?php if ($_POST['eye'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_eye; ?> </td></tr>
<tr><td>Skin Color: </td>
<td> <?php
$skin = array("Skin Color", "White", "Lightly Tinted", "Medium Tinted", "Heavily Tinted", "Brown", "Black");
echo '<select name="skin">';
for($s=0; $s<7; $s++){
if($skin[$s] == $_POST["skin"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$skin[$s].'" '.$selected. '>'.$skin[$s].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="skin" value="<>" <?php if ($_POST['skin'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_skin; ?> </td></tr>
<tr><td>Religion: </td>
<td> <?php
$religion = array("Religion", "Cristian", "Catholic", "Reformed", "Protestant", "Moslim", "Boeddhism", "Hindoeism", "Jewish", "Other", "Atheist");
echo '<select name="religion">';
for($r=0; $r<11; $r++){
if($religion[$r] == $_POST["religion"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$religion[$r].'" '.$selected. '>'.$religion[$r].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="religion" value="<>" <?php if ($_POST['religion'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_religion; ?> </td></tr>
<tr><td>Education: </td>
<td> <?php
$education = array("Education", "VMBO", "HAVO", "VWO", "Grammar School", "Vocational", "College", "University");
echo '<select name="education">';
for($ed=0; $ed<8; $ed++){
if($education[$ed] == $_POST["education"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$education[$ed].'" '.$selected. '>'.$education[$ed].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="education" value="<>" <?php if ($_POST['education'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_education; ?> </td></tr>
<tr><td>Children: </td>
<td> <?php
$order = array("<=", "At most:", "=", "Exactly:", ">=", "At least");
$children= array("Children", "0", "1", "2", "3", "4", "5 or more");
echo '<select name="chorder">';
for ($cho=0; $cho<6; $cho+=2) {
if ($order[$cho] == $_POST["chorder"]) {$selected='selected="selected"'; } else {$selected=''; }
echo '<option value="'. $order[$cho] . '" '. $selected . '>' . $order[$cho+1].'</option>'; }
echo '</select>';
echo '<select name="children">';
for($ch=0; $ch<7; $ch++){
if($children[$ch] == $_POST["children"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'. ($ch-1) .'" '.$selected. '>'.$children[$ch].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="children" value="<>" <?php if ($_POST['children'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_children; ?> </td></tr>
<tr><td>Childwish: </td>
<td> <?php
$childwish= array("Childwish", "0", "1", "2", "3", "4", "5 or more");
echo '<select name="cworder">';
for ($cwo=0; $cwo<6; $cwo+=2) {
if ($order[$cwo] == $_POST["cworder"]) {$selected='selected="selected"'; } else {$selected=''; }
echo '<option value="'. $order[$cwo] . '" '.$selected. '>' . $order[$cwo+1].'</option>'; }
echo '</select>';
echo '<select name="childwish">';
for($cw=0; $cw<7; $cw++){
if($childwish[$cw] == $_POST["childwish"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'. ($cw-1) .'" '.$selected. '>'.$childwish[$cw].'</option>'; }
echo '</select>';
?> <input type="checkbox" name="childwish" value="<>" <?php if ($_POST['childwish'] == "<>" ) { echo 'checked'; } ?>>I don't mind </td>
<td></td> <td><font color="#FF0000"><?php echo $error_childwish; ?> </td></tr>
</table><table>
<tr><td width=120>Smoking: </td>
<td><input type="radio" name="smoke" value="yes" <?php if ($_POST['smoke'] == "yes" ) { echo 'checked'; } ?>>Allowed to smoke
<input type="radio" name="smoke" value="no" <?php if ($_POST['smoke'] == "no" ) { echo 'checked'; } ?>><b>Not</b> allowed to smoke
<input type="radio" name="smoke" value="<>" <?php if ($_POST['smoke'] == "<>" ) { echo 'checked'; } ?>>I don't mind
</td width=10><td></td> <td><font color="#FF0000"> <?php echo $error_smoke; ?> </td></tr>
<tr><td>Ages: </td>
<td>Between <?php
$agemin = array("Age", "18", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75");
echo '<select name="agemin">';
for($a1=0; $a1<13; $a1++){
if($agemin[$a1] == $_POST["agemin"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$agemin[$a1].'" '.$selected. '>'.$agemin[$a1].'</option>'; }
echo '</select>'; ?>
and
<?php
$agemax = array("Age", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80");
echo '<select name="agemax">';
for($a2=0; $a2<13; $a2++){
if($agemax[$a2] == $_POST["agemax"]) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$agemax[$a2].'" '.$selected. '>'.$agemax[$a2].'</option>'; }
echo '</select>'; ?>
years old.
<input type="checkbox" name="age" value="<>" <?php if ($_POST['age'] == "<>" ) { echo 'checked'; } ?> >I don't mind </td>
</td> <td></td> <td><font color="#FF0000"><?php echo $error_age; ?> </td></tr>
</table><br>
<input type="submit" value="Match!"></form>
<form name="reset" method="post" action="<?php echo ($_SERVER["PHP_SELF"]);?>">
<input type="submit" value="Reset">
</form>
<hr>
<form action="profile.php?u=<?php echo $_SESSION['username']; ?>" method="post">
<input type="submit" value="Go to my own profile!"></form>
</body>
</html>
Result.php
Code (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
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
<?php
session_start();
include_once('config.php');
IF (!isset($_SESSION['username'])) { header('Location: '. $homepage); }
IF ($_SESSION['query']== "") { header('Location: matching.php'); }
$con = mysql_connect($SQLhost, $SQLuser, $SQLpass) or die('Could not connect: ' . mysql_error());
mysql_select_db($SQLdb, $con) or die('Could not find database: ' . mysql_error()) ;
IF ($_POST['controle'] == "TRUE") {
$sql_order = "ORDER BY ";
if ($_POST['sort'] == "Jaar") {
if ($_POST['way'] == "ASC") { $sql_order .= "Jaar DESC, Maand DESC, Dag DESC "; }
else { $sql_order .= "Jaar ASC, Maand ASC, Dag ASC"; }
} else {
$sql_order .= $_POST['sort'] ." " . $_POST['way'] . " ";
}
IF (! ($_SESSION['order'] == $sql_order ))
{ $_SESSION['order'] = $sql_order; }
} ELSE {
$_SESSION['order'] = "ORDER BY Jaar DESC, Maand DESC, Dag DESC ";
}
$res = mysql_query( $_SESSION['query'] . " " . $_SESSION['order'] );
IF ($res === false) { echo "Query Error."; }
?>
<html>
<head>
<title>Matching - <?php echo $_SESSION['username']; ?> </title>
<link rel="icon" type="image/ico" href="/dating/favicon.ico"> </link>
</head>
<body bgcolor="<?php echo $_SESSION['background']; ?>">
<?php include('menu.php'); ?>
<hr>
<b>Matching...</b><br />
We found <?php echo mysql_num_rows($res), " results:<br>";
if (mysql_num_rows($res) == 0) {
echo "Want to match again? <br><br>"; } else {?>
<br><table>
<tr><td width=100><b>Name</b></td>
<td width=50><b>Age</b></td>
<td width=65><b>Gender</b></td>
<td width=70><b>Province</b></td>
<td width=90><b>Hair Color</b></td>
<td width=100><b>Skin Color</b></td>
<td width=80><b>Eye Color</b></td>
<td width=70><b>Religion</b></td>
<td width=80><b>Education</b></td>
<td width=70><b>Children</b></td>
<td width=70><b>Childwish</b></td>
<td width=50><b>Smoking</b></td>
</tr>
<?php
for ($i=0; $row = mysql_fetch_assoc($res); $i++)
{ echo "<tr>
<td> " . ($i + 1) . ". <a href='profile.php?u=". $row['Username']."'>".$row['Username']." </td>
<td> " . calcAge($row['Dag'], $row['Maand'], $row['Jaar']) . "</td>
<td> " . $row['Geslacht'] . " </td>
<td> " . $row['Provincie'] . " </td>
<td> " . $row['Haarkleur'] . " </td>
<td> " . $row['Huidskleur'] . " </td>
<td> " . $row['Oogkleur'] . " </td>
<td> " . $row['Religie'] . " </td>
<td> " . $row['Opleiding'] . " </td>
<td style='text-align: center;'> " . $row['Kinderen'] . " </td>
<td style='text-align: center;'> " . $row['Kinderwens'] . " </td>
<td> " . $row['Roken'] . " </td>
</tr>"; }
?>
</table><br>
<table>
<form action="" method="post">
<input type="hidden" name="controle" value="TRUE">
<tr><td>Sort by: </td>
<td> <?php
$sort = array("Age", "Gender", "Province", "Hair Color", "Eye Color", "Skin Color", "Religion", "Education", "Children", "Childwish", "Smoking");
$sorter = array("Jaar", "Geslacht", "Provincie", "Haarkleur", "Oogkleur", "Huidskleur", "Religie", "Opleiding", "Kinderen", "Kinderwens", "Roken");
echo '<select name="sort">';
for($srcn=0; $srcn<11; $srcn++) {
if($sorter[$srcn] == $_POST['sort']) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$sorter[$srcn].'" '.$selected. '>' . $sort[$srcn] . '</option>'; }
echo '</select>';
$way = array("ASC", "DESC"); $wayer = array("Ascending", "Descending");
echo '<select name="way">';
for($asc=0; $asc<2; $asc++) {
if($way[$asc] == $_POST['way']) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$way[$asc].'" '.$selected. '>' . $wayer[$asc] . '</option>'; }
echo '</select>';?>
<input type="submit" value="Sort!"></form>
</table><br>
<?php } ?>
<form action="matching.php" method="post">
<input type="submit" value="Back to Matching screen"></form>
<hr>
<form action="profile.php" method="post">
<input type="submit" value="Go to my own profile!"></form>
</body>
</html>
session_start();
include_once('config.php');
IF (!isset($_SESSION['username'])) { header('Location: '. $homepage); }
IF ($_SESSION['query']== "") { header('Location: matching.php'); }
$con = mysql_connect($SQLhost, $SQLuser, $SQLpass) or die('Could not connect: ' . mysql_error());
mysql_select_db($SQLdb, $con) or die('Could not find database: ' . mysql_error()) ;
IF ($_POST['controle'] == "TRUE") {
$sql_order = "ORDER BY ";
if ($_POST['sort'] == "Jaar") {
if ($_POST['way'] == "ASC") { $sql_order .= "Jaar DESC, Maand DESC, Dag DESC "; }
else { $sql_order .= "Jaar ASC, Maand ASC, Dag ASC"; }
} else {
$sql_order .= $_POST['sort'] ." " . $_POST['way'] . " ";
}
IF (! ($_SESSION['order'] == $sql_order ))
{ $_SESSION['order'] = $sql_order; }
} ELSE {
$_SESSION['order'] = "ORDER BY Jaar DESC, Maand DESC, Dag DESC ";
}
$res = mysql_query( $_SESSION['query'] . " " . $_SESSION['order'] );
IF ($res === false) { echo "Query Error."; }
?>
<html>
<head>
<title>Matching - <?php echo $_SESSION['username']; ?> </title>
<link rel="icon" type="image/ico" href="/dating/favicon.ico"> </link>
</head>
<body bgcolor="<?php echo $_SESSION['background']; ?>">
<?php include('menu.php'); ?>
<hr>
<b>Matching...</b><br />
We found <?php echo mysql_num_rows($res), " results:<br>";
if (mysql_num_rows($res) == 0) {
echo "Want to match again? <br><br>"; } else {?>
<br><table>
<tr><td width=100><b>Name</b></td>
<td width=50><b>Age</b></td>
<td width=65><b>Gender</b></td>
<td width=70><b>Province</b></td>
<td width=90><b>Hair Color</b></td>
<td width=100><b>Skin Color</b></td>
<td width=80><b>Eye Color</b></td>
<td width=70><b>Religion</b></td>
<td width=80><b>Education</b></td>
<td width=70><b>Children</b></td>
<td width=70><b>Childwish</b></td>
<td width=50><b>Smoking</b></td>
</tr>
<?php
for ($i=0; $row = mysql_fetch_assoc($res); $i++)
{ echo "<tr>
<td> " . ($i + 1) . ". <a href='profile.php?u=". $row['Username']."'>".$row['Username']." </td>
<td> " . calcAge($row['Dag'], $row['Maand'], $row['Jaar']) . "</td>
<td> " . $row['Geslacht'] . " </td>
<td> " . $row['Provincie'] . " </td>
<td> " . $row['Haarkleur'] . " </td>
<td> " . $row['Huidskleur'] . " </td>
<td> " . $row['Oogkleur'] . " </td>
<td> " . $row['Religie'] . " </td>
<td> " . $row['Opleiding'] . " </td>
<td style='text-align: center;'> " . $row['Kinderen'] . " </td>
<td style='text-align: center;'> " . $row['Kinderwens'] . " </td>
<td> " . $row['Roken'] . " </td>
</tr>"; }
?>
</table><br>
<table>
<form action="" method="post">
<input type="hidden" name="controle" value="TRUE">
<tr><td>Sort by: </td>
<td> <?php
$sort = array("Age", "Gender", "Province", "Hair Color", "Eye Color", "Skin Color", "Religion", "Education", "Children", "Childwish", "Smoking");
$sorter = array("Jaar", "Geslacht", "Provincie", "Haarkleur", "Oogkleur", "Huidskleur", "Religie", "Opleiding", "Kinderen", "Kinderwens", "Roken");
echo '<select name="sort">';
for($srcn=0; $srcn<11; $srcn++) {
if($sorter[$srcn] == $_POST['sort']) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$sorter[$srcn].'" '.$selected. '>' . $sort[$srcn] . '</option>'; }
echo '</select>';
$way = array("ASC", "DESC"); $wayer = array("Ascending", "Descending");
echo '<select name="way">';
for($asc=0; $asc<2; $asc++) {
if($way[$asc] == $_POST['way']) {$selected='selected="selected"'; } else {$selected='';}
echo '<option value="'.$way[$asc].'" '.$selected. '>' . $wayer[$asc] . '</option>'; }
echo '</select>';?>
<input type="submit" value="Sort!"></form>
</table><br>
<?php } ?>
<form action="matching.php" method="post">
<input type="submit" value="Back to Matching screen"></form>
<hr>
<form action="profile.php" method="post">
<input type="submit" value="Go to my own profile!"></form>
</body>
</html>
Gewijzigd op 19/11/2013 14:52:46 door Kevin Zegikniet