Obtain Client IP & Store To DB

Is there a Wappler way, i.e. use dmx-browser, rather than a PHP script to get client ip and url so they can be stored to database?

Here’s what I have found and currently using:

<?php
    if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
    $ip = $_SERVER["HTTP_CLIENT_IP"];
    }
    else if (!empty($_SERVER["HTTP_X_FORWARD"])) {
    $ip = $_SERVER["HTTP_X_FORWARD"];
    }
    else {
    $ip = $_SERVER["REMOTE_ADDR"];
    }
?>

Then in the insert form I have this:

<!-- hidden -->
<input type="hidden" name="ip_address" value="<?php echo $ip; ?>" />
<input type="hidden" name="url_address" dmx-bind:value="browser1.location.origin + '' + browser1.location.pathname">
<!-- hidden -->

This works okay. However, instead of using PHP code, I would prefer to use a dmx-bind:value with a browser component that retrieves the IP address of the client.

Is such a thing available?

Community Page
Last updated: