Add variables to $_GET for url link

When working with links containing forms on the same page, you sometimes don’t want to lose the data. Especially if you switch languages after a search. You can easily build a query with old and new variables. //php $variables = array_merge($_GET, array(“a” => “value1”, “b” => “value2”)); $queryString = http_build_query($variables); //Result: ?old1=that&old2=this&a=value1&b=value2

Tags:
Read More

Get user IP address

Sometimes we want to get the user ip address right away for verification purposes. This is the most efficient version that I found online. //Ref: http://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php if (!empty($_SERVER[‘HTTP_CLIENT_IP’])) { $ip = $_SERVER[‘HTTP_CLIENT_IP’]; } elseif (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’])) { $ip = $_SERVER[‘HTTP_X_FORWARDED_FOR’]; } else { $ip = $_SERVER[‘REMOTE_ADDR’]; }

Tags:
Read More

Fix or modify an element on page at a scroll position

Fix a second header as main header on scroll down or any animation or event at a specific scroll position. You can add more if statements to produce stepping(parallax) effects. /*css*/ .fixed{ width:100%; position:fixed; top:0; left:0; } //jquery $(window).on(‘scroll’, function () { var position = Math.round($(window).scrollTop()); if (position > 100) { $(“div.column-map”).addClass(“fixed”); } else { […]

Tags:
Read More