-
Notifications
You must be signed in to change notification settings - Fork 0
/
include.php
36 lines (29 loc) · 1.01 KB
/
include.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
<?php
function setGetDbData ($wordArray) {
//connect to the database
$dbLink = mysql_connect('localhost', 'worduser', 'wordpass');
if (!$dbLink) {
die('Could not connect: ' . mysql_error());
}
//pull some stuff from the database
$result = mysql_query('SELECT `word` FROM devops.wordsList');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
while ($row = mysql_fetch_assoc($result)) {
$wordArray[] = $row['word'];
}
}
function displayform() {
return
'<form action="index.php">
<input type="text" name="theword" />
<input type="submit" name="submit" />
</form>';
}
function checkWord () {
if ( !isset( $_GET['theword'] ) || trim($_GET['theword']) == "" ) return null;
$wordArray = array();
setGetDbData(&$wordArray);
return in_array(trim($_GET['theword']),$wordArray) ? 1:-1;
}