1

On my company's website I want to have a form where a visitor can provide an email address and pass an anti-bot challenge. The server would then email a trial key to the visitor.

Background: I am integrating a third-party software licensing solution into my PC software products. This enables users to use a key of the form "1234-56789-ABCDE-F0123" to activate a limited demo version of my software. Unfortunately, I could not find a licensing vendor offering a simple online service to deliver trial keys via email so I am planning to roll my own such service.

When a user submits an email address it is checked against a list of stored addresses. If he has registered before, his previous key is resent. If the email address is new, a fresh trial key is sent out from a preloaded list of, say, 1000 keys. All data (contact info and keys) must be stored securely and there needs to be a basic maintenance portal allowing manipulation and of the database. Other functionality may follow (e.g. multiple demo versions, capturing more than email address from form).

This is the only dynamic page on my website - everything else is pretty much static HTML. What is a good way to implement this behaviour on low cost / ubiquitous hosting (e.g. MySQL, cPanel, etc.)? What platform/language/CMS/services should I leverage?

I may hire someone to write scripts, etc. but I first need direction on which platform I should look at. Many thanks.

2 Answers 2

1

Hosting with cPanel, MySQL and PHPMyAdmin (which gives you access to the backend of the database(s)) should be sufficient. Any web scripting language could do what you want, so it may be best to let the person you hire choose. PHP is an obvious choice, and when you want something changed it's likely you could find someone else to help you if the original person isn't even available.

2
  • Thanks - PHP doesn't sound too tough. Does PHP come with whatever tools are necessary to make sure that mail is not bounced by recipients' servers?
    – paperjam
    Commented May 27, 2011 at 12:29
  • Why would it be bounced? Because the servers think it's spam or some other reason? Commented May 27, 2011 at 12:59
1
  1. Set a DB with "key", "status", and "client" fields.
  2. Search the client email in the DB
  3. If exists, send the asociated key
  4. Else, query the DB looking for the first key with status "not activated" or something like that and echo it.

form.php Just a normal form with email and submit. Should use method POST to validate.php

validate.php

<?php
$dbhost = $host; //Use a require file to load your data or replace this ones
$dbname = $base; //
$dbuname = $user; //
$dbpass = $pass; //
$email = $POST_["email"];
$TableName = "keys";
$Link = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuname, $dbpass);
$Query = "SELECT * FROM $TableName WHERE email LIKE $email";
$Result = $Link->query($Query);
if (!$Result) {
    $Query = "SELECT * FROM $TableName WHERE status LIKE 'inactive' LIMIT 1";
    $Result = $Link->query($Query);
    echo $row[key];
} else {
while ($row = $Result->fetch(PDO::FETCH_ASSOC)) {
    echo $row[key];
}
}
?>

You probably should add another exception in case there is no keys left and also complete the PHP code in the validate.php (right now it just echoes the keys).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.