-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsubmit.php
More file actions
executable file
·45 lines (33 loc) · 924 Bytes
/
submit.php
File metadata and controls
executable file
·45 lines (33 loc) · 924 Bytes
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
<?php
/*
* CodeWeavers Web Test (PHP Side)
*/
define("DBFILE", "data/data.db");
require("include/db.php");
$db = new dataDB(DBFILE);
header("Content-type: application/x-javascript; charset=UTF-8");
if (empty($_POST) or empty($_POST['mail'])) {
echo json_encode("INCOMPLETE");
exit();
}
$fields = array('fname','lname','email','rdate');
$row = array();
foreach ($fields as $p) {
$row[$p] = trim($_POST[$p]);
}
try {
$r = $db->querySingle('SELECT id FROM users WHERE email = "{$row[email]}"');
if ($r->id)
throw new Exception('EMAIL_EXISTS');
$db->exec("INSERT INTO users VALUES(0,'".implode("','",$row)."')");
if ($db->lastErrorCode())
throw new Exception($db->lastErrorMsg());
if (!$db->lastInsertRowID())
throw new Exception('DB_ERROR');
} catch (Exception $e) {
echo json_encode($e->getMessage());
exit();
}
echo json_encode("OK");
exit();
?>