function tag_exists($tagger_id, $runner_id) { $runner_id = clean_runner_id($runner_id); $tagger_id = clean_chaser_id($tagger_id); if (!is_valid_runner($tagger_id) || !is_valid_runner($runner_id)) { print "Invalid runner or tagger id<br/ >"; return false; } $mysql = connectdb(true); $query = "SELECT tag_id FROM " . TAGS_TBL . " WHERE tagger_id = '" . $tagger_id . "' AND runner_id = '" . $runner_id . "'"; $result = mysql_query($query, $mysql); if (mysql_num_rows($result) > 0) { return true; } else { return false; } }
<html> <body onload="setTimeout(function() { window.scrollTo(0, 1) }, 100);"> <?php //user has a jlog-rid cookie set, so this means they scanned the qr code of someone they tagged include 'mobile-friendly.html'; include 'functions.php'; print '<h2>Journey Log</h2>'; $tagger_id = clean_chaser_id($_GET['tid']); $runner_id = clean_runner_id($_GET['rid']); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $tagger_id = clean_chaser_id($_POST['tagger_id']); $runner_id = clean_chaser_id($_POST['runner_id']); $loc_lat = $_POST['latitude']; $loc_long = $_POST['longitude']; $loc_addr = $_POST['address']; if (empty($loc_lat)) { $loc_lat = 0; } if (empty($loc_long)) { $loc_long = 0; } print '<p><span style="color:red;">Chaser ' . get_runner_name($tagger_id) . '</span> tagged <span style="color:blue;">Runner ' . get_runner_name($runner_id) . '</span> at ' . $loc_lat . ',' . $loc_long . '.<br />'; if (is_valid_runner($tagger_id) && is_valid_runner($runner_id)) { if (register_tag($tagger_id, $runner_id, $loc_lat, $loc_long, $loc_addr)) { print '<div style="font-size:14em;color:green;text-align: center;">✓</div><h3>Your tag is checked in!</h3>'; } else { if (tag_exists($tagger_id, $runner_id)) { print '<h3>You\'ve already tagged this runner!</h3><div style="font-size:14em;color:red;text-align: center;">X</div>'; } else { print '<h3>Oops, something is broken</h3><div style="font-size:14em;color:red;text-align: center;">X</div>';