-
Notifications
You must be signed in to change notification settings - Fork 1
/
recordMove.php
38 lines (36 loc) · 1.16 KB
/
recordMove.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
<?php
//recordMove.php
$color = $_REQUEST['color'];
$x = $_REQUEST['x'];
$y = $_REQUEST['y'];
$cube = $_REQUEST['cube'];
$face = "#";
if((strlen($color) <= 6) && (strlen($x) <= 4) && (strlen($y) <= 4) && (strlen($cube) <= 2)) {
$database = "glassplategame_com";
$link = mysql_connect("localhost", "caploc", "REDACTED");
if(!$link)
die("Could not connect to MySQL");
mysql_select_db($database)
or die ("Couldn't open db" . mysql_error());
if (isset($cube)) {
$piece = mysql_real_escape_string($cube);
$color = mysql_real_escape_string($color);
$x = mysql_real_escape_string($x);
$y = mysql_real_escape_string($y);
$face = mysql_real_escape_string($face);
$result = mysql_query("SELECT * FROM gpgmoves");
$num_rows = mysql_num_rows($result);
if(($cube - 1) == $num_rows) {
$sql = "INSERT INTO gpgmoves SET piece='$piece', color='$color', x='$x',
y='$y'";
}
else {
$sql = "UPDATE gpgmoves SET piece='$piece', color='$color', x='$x',
y='$y', face = '$piece' WHERE id='$piece'";
}
$result = mysql_query($sql);
if (!$result) die(mysql_error());
}
}
mysql_close();
?>