Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //connect to database by including connection file.
- require_once('connect.php');
- //get variables passed from form.
- $key = $_POST['key'];
- //sanitize input to prevent SQL injection
- $key = strip_tags($key);
- // further sanitization using mysql real escape
- $key = mysql_real_escape_string($key);
- //query database to first check that the key exists.
- $sql = "SELECT * FROM wills95_licence_key_generator.licencekeys WHERE keycode = $key ";
- //Run the query to find all results.
- $query = mysql_query($sql);
- echo $query;
- //get the array
- $key_array = mysql_fetch_array($query);
- echo $key_array;
- $value = $key_array['keycode'];
- echo $value;
- //Count the number of rows to ensure 1 row is found
- //echo the value of rows to ensure row count is working correctly.
- echo "This should return the value of 1: ";
- echo "<br />";
- echo $rows;
- //If statement to confirm that row exists.
- If($rows==1) {
- //select key and retrieve the active setting, this will return either YES or NO.
- $sql_2 = "SELECT active FROM wills95_licence_key_generator.licencekeys WHERE keycode = $key ";
- $query_2 = mysql_query($sql_2);
- //now echo out the variable to see what the output is.
- echo "The result of your key check is below, if NO is displayed, the key is not activated, if YES is displayed, the key has already been activated and is no longer valid";
- echo $query_2;
- } else {
- echo "That key was not found in our database";
- }
- //end script.
- //*Copyright William Shelley 2013*//
- ?>
Advertisement
Add Comment
Please, Sign In to add comment