Single use access codes

PHP

Lets say you need to build an application that provides one time access to some information. It can be some files you let your users download, or some game they want to play, or some video to watch. Instead of distributing some sort of usernames and passwords you want to make this experience as easy as possible and provide access based on a simple numeric code. Such code can sent via email or text messages or handed as scratch card similar to one below.



1. We are going to need a simple database table to store those codes. Besides the code code itself we also need to store the status. Status field is empty if code never been used and contains ‘used’ otherwise.

2. Add this table to project, enable Add page and proceed to Page Designer. This is the only page we going to need for now. Remove all elements that you don’t need to see. We want to make this page as light as possible, we only need a title, an input box and a submit button. Make sure to change labels accordingly.

3. Proceed to Editor, right click on this Add page and make sure it is set as a Landing page.

4. Add the following code to Custom Add event (PHPRunner).

5. In this code we use Database API to find if such code exists. If it doesn’t – we display the error message. If it exists but was used already – we will display another message. If code exists and wasn’t used – we should allow user access to some sort of information. For now we are just saying that code is correct.

6. Next steps. For clarify purposes we don’t do anything after code was verified. Here is a sample code that will logon user to your application and redirect them to some other page.

Note: if you add login to your project make sure you also enable Guest login and provide Guest users access to this Add page.

More info:
Database API
Security API

3 thoughts on “Single use access codes

  1. I have to say one thing. The developer of this unique software has done an amazing job to always stay on cutting edge of software development. This tool has enabled not just starters, but advanced developers to create applications on the fly. Thank you so much for this great tutorial!

Leave a Reply

Your email address will not be published. Required fields are marked *