Created
October 25, 2017 09:52
-
-
Save shmidtelson/0c2afcbf365ee745f6e5c4b59d0039f2 to your computer and use it in GitHub Desktop.
Adding timezone to db (/ajax/setBreakfast.php)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
require( 'settings.php' ); | |
require( 'system.php' ); | |
$system = new System; | |
$system->db = $db; | |
$token = $system->secureField( $_POST["token"] ); | |
$breakfast = $system->secureField( $_POST["breakfast"] ); | |
$tzone = $system->secureField( $_POST["timezone"] ); | |
$time = time(); | |
$check_exist = $db->query( " | |
Select id from app_tokens where token = '$token' limit 1 | |
" ) | |
or die( mysqli_error( $db ) ); | |
if ( $check_exist->num_rows > 0 ) { | |
$db->query( "UPDATE app_tokens SET | |
breakfast = '$breakfast', | |
updated = '$time', | |
tzone = '$tzone' | |
WHERE token = '$token'" ) | |
or die( mysqli_error( $db ) ); | |
} else { | |
$db->query( "INSERT INTO app_tokens (token,breakfast,created,updated,tzone) values ('$token','$breakfast','$time','$time','$tzone')" ) | |
or die( mysqli_error( $db ) ); | |
} | |
die(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment