PHP - Php Detect Browser Close
I have a problem, where i need to know when user leave or close tha browser tab. I tryd to make a ajax post, after unload, make a POST into kill_browser.php and after 1 minute when session_expire, php code will be execute and save time into database. But it not seems to work :/ I'm glad if some 1 can say what im doing wrong, or is there eny better way to detect it.
@home.php
var leaved = 'leaved';
$(window).unload( function(){ $.ajax({ url: 'kill_browser.php', global: false, type: 'POST', data: leaved, async: false, success: function() { console.log('leaved'); } }); }); @kill_browser.php <?php require('class/connection.php'); $conn = new connection(); session_cache_limiter('private'); $cache_limiter = session_cache_limiter(); session_cache_expire(1); $cache_expire = session_cache_expire(); session_start(); $_SESSION['leaved'] = $_POST['leaved']; if($_SESSION['leaved'] == null || $_SESSION['leaved'] == " "){ $conn->logOut($_SESSION['userID'], $_SESSION['userIP'], $_SESSION['LAST_GENERATED_ID']); session_regenerate_id(true); unset($_SESSION); session_destroy(); header('location:index.php'); } ?> Similar TutorialsHi there, I've looked into the PHP superglobal array $_SERVER, but could not find a variable that stores the plugins a client has on his/her browser such as firefox and google chrome. The point here is to detect if a user has hacking addons such as firebug and inspect element installed, and displays an error message telling the user to disable such plugins in order to access site content. Is it possible to accomplish such tasks? Please help. Hi there, I was wondering if it is possible to (on the closing of a browser to a logged in user) to automatically destroy that session. Thanks in advance. i am trying to set user status as offline when user close browser but i am facing a problem ... i am calling a function when body unload which will set guest user status to "0" when user close the browser but it not working ... it execute php before function is called.. any idea why this is happening ...please help it's making me crazy Hello. Would php be the right thing to use in regards to monitoring changes in html on certain pages, Basicly, I'd need it to be something like: "Page last changed: 2 Days, 4 Hours, 34 Minutes and 13 Seconds ago." What would I use for this? Thanks Ok, so I have a code that looks like so: Code: [Select] <script type="text/javascript"> var ng_config = { assests_dir: 'ng/assets/' // the path to the assets directory } </script> <script type="text/javascript" src="ng/ng_all.js"></script> <script type="text/javascript" src="ng/components/calendar.js"></script> <script type="text/javascript"> var my_cal; ng.ready(function(){ // creating the calendar var my_cal = new ng.Calendar({ input: 'enddate', start_date: 'year - 1', // the start date (default is today) display_date: ng.get('startdate').value, // the display date (default is start_date) server_date_format: 'm/d/Y' // changing the server date format for a specific calendar. }); }); var my_cal1; ng.ready(function(){ // creating the calendar my_cal1 = new ng.Calendar({ input: 'startdate', start_date: 'year - 1', // the start date (default is today) display_date: new Date(), // the display date (default is start_date) server_date_format: 'm/d/Y' // changing the server date format for a specific calendar. }); }); how do I detect the months that pass between the two dates that are selected using a popup calendar using php so that my register page know which month to display the event under. Does this make sense? Code: [Select] if ($showigiteidimage) { $igitwid_divlnk = "onclick=location.href='" . get_permalink($igitwid_result->ID) . "'; style=cursor:pointer;"; $igitwid_output .= '<li id="igit_wid_rpwt_li" style="height:' . $igitwid_height . 'px; padding-bottom: 10px;" ' . $igitwid_divlnk . '>'; $igitwid_output .= '<div id="igit_wid_rpwt_main_image" style="float:left;"> <a href="' . get_permalink($igitwid_result->ID) . '" target="_top"><img src="<?php $values = get_post_custom_values("tj_video_img_url"); echo $values[0]; ?>" id="igit_rpwt_thumb" ></a></div>'; the prb is image src cant read the php code , what to do ? please helpppppppppp Hi, Would time() produce the timestamp based on your time environment or the servers?, if it produces the timestamp based on the server; how would I generate a timestamp (which I can later use within date()); so it displays to the users timezone? I am making a demo page that I want to add a form to. The way I want this for to work is. Say you are at demo.com Now you are a client I am working with so I have given you a number. This form will as for that number and on submit it will take you to demo.com/"client number" Here is what I have done. What is in my index.php <form> <form action="search.php"> <input id="button" name="button" type="text" /> <input type="button" value="SEARCH" > </form> What is in my search.php <?php $newurl = "http://demo.mysite.com/"; $newurl .=$_GET['button']; echo "$newurl"; /*header("Location: $newurl"); */ ?> -------------------------------------------------- I have also tried taking out the search.php and having everything in index.php <form> <form> <input id="button" name="button" type="text" /> <input type="button" value="SEARCH" > </form> <?php $newurl = "http://demo.mysite.com/"; $newurl .=$_GET['button']; echo "$newurl"; /*header("Location: $newurl"); */ ?> I was wondering if there was a way or if it's even possible to determine the type of a proxy using php. When I say type I mean http, socks4 or socks5. Using cURL I think it's safe to assume that if a proxy returns a code of 200 then that proxy is good and http, correct? However, how would I go about determining the type of proxies I have in a list, assuming they are good and socks4 and/or socks5? In the site I am making, the client wants one account for everyone (don't ask me why, it's a long, silly reason) And I'm wondering how I would configure mySQL to deal with that (I asked this in the mySQL area) and in PHP (For you guys ) what would I need to put in order for this to work. I'm very new with PHP and mySQL, so please forgive the nooby question. *EDIT* the admins have their own username and psw for adding, deleting, and editing articles. and that works. But all users that register will have this set user and psw displayed to them. I want to make it so they have to log in to see an article. Hi, how can i detect if my website is being open in mobile type all devices instead of computer Please help Hi, I have tried a lot of different scripts for detect and redirect for device for mobile and they seem to work ok on mac but ie does not load the page are there any scripts that work? I have a main site that sits at the usual www.domain.co.uk address and then i have a mobile site at www.domain.co.uk/phone i want to be able to have nay mobile users when accessing www.domain.co.uk be automaticly redirected to www.domain.co.uk/phone with that working in ie? any help please? thanks, When displaying a webpage within iframe of facebook fan page, how I can detect that my page is viewed within the facebook iframe? I want to have a if else statement to change something within the page if it is viewed through facebook fanpage (not by direct visit). This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=326450.0 Basically what the title says, I want to detect a upload and post a notification, how would i do this? php can detect "mac address", "ip address", "browser agent", "cookie" and "hostname". What else php can detect? Hi guys, I have this code: <?php // This Code Works if (isset($_POST{"PantryID"})) { Create_Pantry($_POST{"PantryID"}); } // This Code Isn't Working, Keeps Going To 'Else'. if (isset($_POST{"ItemName"})){ Add_Item($_POST{"ItemName"}, $_POST{"ItemWeight"}, $_POST{"ItemPrice"}, $_POST{"ItemDate"}); }else{ echo "Nothing To do"; } ?>
here is the html <label for="PantryID">Create Pantry: </label> <input type="text" id="PantryID" name="PantryID" disabled="true" /> <label for="ItemName">Item Name: </label> <input type="text" id="ItemName" name="ItemName" disabled="true" /> Please help, I can't find any syntax errors. - At the point the PHP is activated it is no longer disabled. the PantryID is set up the same way. Edited September 27, 2020 by jahickiCorrection How can I detect if the page was refreshed? I thought the following worked, however, after much head scratching, discovered it does not work for a POST request using the Chrome browser. Thanks
<?php $refresh=isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0'; echo(($refresh?'refresh':'not refresh').'<br>'); echo('$_GET<pre>'.print_r($_GET,1).'</pre>'); echo('$_POST<pre>'.print_r($_POST,1).'</pre>'); ?> <ul> <li><a href="refresh.php?id=1">one</a></li> <li><a href="refresh.php?id=2">two</a></li> <li><a href="refresh.php?id=3">three</a></li> </ul> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="text" name="text" value="hello"> <input type="submit" name="submit" value="submit"> </form> Hi everyone. I have a small problem. I have a database that shows student images, in the format of 1234.jpg but the file name extension is in both upper case and lower case. My server OS is linux ubuntu. apache2 php5. Linux see these as 2 different file so will not show the upper case ones. 1234.JPG What i have already is working but for lower case only, i need something to detect when the extension is in uppercase and change accordingly. This is what i have now that works for lower case only. <img src=../images/mbr_images/<?php echo H($mbr->getBarcodeNmbr());?>.jpg height=150 width=100 border=1px </img This is what i have tried but gives me a filename of "1234jpg" see the "." is missing? and is still lower case. <img src=../images/mbr_images/<?php echo H($mbr->getBarcodeNmbr()); $image = jpg; $image2 = JPG; if ($image = $image) { echo $image; } else { echo $image2; };?> height=150 width=100 border=1px </img> can anyone offer any help please? TIA Peter |