We work hard in order to make your user's experience an easy one to vote for your site AND receive in-game incentives. It is a relatively simple and secure process that can be easily implemented with minimal programming experience.

Overview

Every time a user votes for your site, this information is sent back to your site, so that you know that you are gaining more votes. All information regarding votes is sent to your specified page (User Referral URL) through POST which you can then use to track your site's growth in popularity! On the "modify site" page for your site, all you need to do add a page for the "User Referral URL" field and we'll start sending you information about all of the votes!

Sample Voting Link


<a href="http://www.virtualpetdirectory.com/site/vote/{your-site-clean-name}?user={your voter's username/id}">Vote on VPD!</a>
    

Each of the things in curly braces ({}) are values that you will need to provide.

  • {your-site-clean-name} - Listed on the "modify site" page under the "Clean Name" section on the left hand panel
  • {your voter's username/id} - Something unique from your site that will identify a specific user (will be sent back to you)

Sample Script


<?php
/**
 * Sample post-back script for Virtual Pet Directory.
 * 
 * Assumption:
 *  - you are using the "mysqli" functions for database queries
 */

// The API Key as listed on your "modify site page"
$API_KEY = 'YOUR_API_KEY';

// Include database connection here

// Verify that the API Key matches what you expect it to
if($_POST['API_KEY'] != $API_KEY)
{
    // The API Key doesn't match, so we should ignore the vote (someone is spoofing the POST)
    return;
}

// Now that we know that the request is valid, process the vote
// Check if there was a query string parameter passed (assuming your parameter was "user")
if(isset($_POST['QUERY_STRING']) && isset($_POST['QUERY_STRING']['user']))
{
    // It was, so look up the user and give them the benefits
    $stmt = $mysqli->prepare('SELECT id FROM users WHERE username = ?');

    // Bind the username
    $stmt->bind_param('s', $_POST['QUERY_STRING']['user']);

    // Run the query
    $stmt->execute();

    // Bind the result to a $user variable
    $stmt->bind_result($user);

    // Grab the value
    $stmt->fetch();

    // Close the query
    $stmt->close();

    // Check if the user existed
    if(!empty($user))
    {
        // They did, so give them some incentives for voting
        $stmt->prepare('UPDATE users SET points = points + 10, votes = votes + 1 WHERE username = ?');

        // Bind the user id
        $stmt->bind_param('s', $_POST['QUERY_STRING']['user']);

        // Run the query
        $stmt->execute();

        // Close the query
        $stmt->close();
    }
}
    
Advertisements Here - Use the "Contact" link for more information

placeholder
placeholder
placeholder
placeholder
placeholder