AutoID URL

What happens?

Given a Bar code message with an AutoID URL:

HTTPS://WWW.E-D-C.INFO/AUTOID?.25P=QCELMIAQ7B4&.S=400D02

(from the sample code sheet: autoid_url_samples.pdf)

This URL contains the data identifier fields:

(25P)QCELMIAQ7B4
(S)400D02

Those fields are detected by the web server and a data base lookup is initiated to show relevant product information.

Server side implementation

Server side implementation is done using the PHP server language. It consists of the following steps:

DI detection in URL query string

The server on the manufacturer side will detect the passed data identifier. The following PHP code line is sufficient to detect and use the DI fields. The script should search for underscore instead point, because any point or space is replaced by an underscore.

if (is_string($_GET["_25P"]) && is_string($_GET["_S"])) {
    // Product code and serial number found
    ...

Check passed data

For security reasons, any received string should be checked for a restricted character set and length. Due to that, security issues like sql injection or script injection may be avoided.

In this case, we check for alphanumerical data and length between 1 and 52 characters:

    $ProductCode = $_GET["_25P"];
    $Serial = $_GET["_S"];
    if ( ctype_alnum($ProductCode) && strlen($ProductCode) < 53
         && ctype_alnum($Serial) && strlen($Serial) < 53 ) {
        ...

Data base lookup

The next step is to perform the data base lookup to get the state of the item.

        $Status = DataBaseLookup($ProductCode,$Serial);

Return result

The result is returned via the resulting web page:

        <table class="analyse"><caption>Item information</caption>
            <tr><td width=50%>Product Code</td><td><?php echo htmlentities($ProductCode);?></td></tr>
            <tr><td>Serial number</td><td><?php echo htmlentities($Serial);?></td></tr>
            <tr><td>Status</td><td><?php echo htmlentities($State);?></td></tr>
        </table>

Unicode support

AutoID URL is defined using UTF-8 encoding. In consequence, the whole unicode character set is supported. So, adding a DI "1H" with the user name "ÖLMANN" would result in the URL:

HTTPS://WWW.E-D-C.INFO/AUTOID?.25P=QCELMIAQ7B4&.S=400D02&.1H=%c3%96LMANN

The character "Ö" is encoded in UTF-8 resulting in the numbers 195 and 150. Those numbers are then represented by percent encoding "%c3%96" within the URL query string data.

The PHP framework automatically cares about the UTF-8 transformation of the passed data. There is no additional work on the server side. In the current example, no charcter outside the alphanumeric range "0-9A-Za-z" will be accepted due to the "ctype_alphanum" check. This has to be modified to support other character sets.


Service by EURODATA Council Institute e.V.