View difference between Paste ID: La8255fh and gg3sEH87
SHOW: | | - or go back to the newest paste.
1-
<?
1+
<?php
2
/* Start Config */
3-
	/* Start Config */
3+
4
define("DATABASE_USERNAME", ""); // Database Username
5-
	define("DATABASE_USERNAME", ""); // Database Username
5+
define("DATABASE_PASSWORD", ""); // Database Password
6-
	define("DATABASE_PASSWORD", ""); // Database Password
6+
define("DATABASE_HOST", "localhost"); // Database Host
7-
	define("DATABASE_HOST", "localhost"); // Database Host
7+
define("DATABASE_NAME", ""); // Database Name
8-
	define("DATABASE_NAME", ""); // Database Name
8+
define("REMOTE_IP", $_SERVER['REMOTE_ADDR']); // Client's IP
9-
	define("REMOTE_IP", $_SERVER['REMOTE_ADDR']); // Client's IP
9+
10
	/**
11-
	/* Database Note:
11+
	* Database Note:
12-
		Table should be called: cookies
12+
	*  Table should be called: cookies
13-
		Two text rows called: ip & cookienum
13+
	*  Two text rows called: ip & cookienum
14
	*/
15
16-
	/* End Config */
16+
/* End Config */
17
18-
	/* Connect to database */
18+
/* Connect to database */
19-
	mysql_connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD) or die(mysql_error());
19+
mysql_connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD) or die(mysql_error());
20-
	mysql_select_db(DATABSE_NAME) or die(mysql_error());
20+
mysql_select_db(DATABASE_NAME) or die(mysql_error());
21
22-
	/* Check Database For Record */
22+
/* Check Database For Record */
23-
	$query = mysql_query("SELECT * FROM cookies WHERE ip = '" . REMOTE_IP . "' LIMIT 1");
23+
$query = "SELECT * FROM cookies WHERE ip = '" . REMOTE_IP . "' LIMIT 1";
24-
	$result = mysql_query($query) or die(mysql_error());
24+
$result = mysql_query($query) or die(mysql_error());
25
26-
	/* If the record exists */
26+
/* If the record exists */
27-
	if( $result ){
27+
if( $result ){
28-
		
28+
29-
		$row = mysql_fetch_array($result) or die(mysql_error());
29+
	$row = mysql_fetch_array($result) or die(mysql_error());
30-
		$CLIENT_TOTAL_COOKIES = $row['cookienum'] + 1;
30+
	$CLIENT_TOTAL_COOKIES = $row['cookienum'] + 1;
31
32-
		/* Since the record exists, lets update the amount of "cookies" they have */
32+
	/* Since the record exists, lets update the amount of "cookies" they have */
33-
		if( mysql_query("UPDATE cookies SET cookienum = cookienum + 1 WHERE ip = '" . REMOTE_IP . "' LIMIT 1") ){
33+
	if( mysql_query("UPDATE cookies SET cookienum = cookienum + 1 WHERE ip = '" . REMOTE_IP . "' LIMIT 1") )
34-
			echo "Cookies have been added");
34+
	echo "Cookies have been added";
35-
		}else{
35+
	else
36-
			die(mysql_error());
36+
	die(mysql_error());
37-
		}
37+
38-
		
38+
39
} else {
40-
	}else{
40+
41-
		
41+
	/* Insert record into database */
42-
		/* Insert record into database */
42+
	if( mysql_query("INSERT IGNORE INTO cookies ( ip, cookienum ) VALUES( '" . REMOTE_IP . "', '1'") )
43-
		if( mysql_query("INSERT IGNORE INTO cookies ( ip, cookienum ) VALUES( '" . REMOTE_IP . "', '1'") ){
43+
	echo "Your record has been added!";
44-
			echo "Your record has been added!");
44+
	else
45-
		}else{
45+
	die(mysql_error());
46-
			die(mysql_error());
46+
}
47-
		}
47+