damerit Posted June 3, 2008 Share Posted June 3, 2008 I have an internal web application in php and mysql. I'm looking to log every time the user clicks on a specific link. The user clicks a link to view a record and the session userID, timstamp, and a running count for this record is posted to my mysql table. It has been mentioned to use the onload event. But I'm not sure of how to use the onload-event and post to a database. All I want to do is when either the hyperlink is clicked on or the page loads to send the user information of userID and timestamp to the database. What is the best method of posting this information to the database? thks, dvd Link to comment https://forums.phpfreaks.com/topic/108579-posting-to-mysql-on-load-event/ Share on other sites More sharing options...
jonsjava Posted June 3, 2008 Share Posted June 3, 2008 is the link internal, or external? if it's external, then you need to use a redirect page (a layover, if you like) to handle that. If it's internal, just run the query at the top of the page, before anything is output to the screen. Link to comment https://forums.phpfreaks.com/topic/108579-posting-to-mysql-on-load-event/#findComment-556783 Share on other sites More sharing options...
damerit Posted June 3, 2008 Author Share Posted June 3, 2008 The links are all internal. So, you mean to run a query at the top of the page and it will post. $userid = $_GET['userid']; $timestamp = $_GET['timestamp']; $q = "select image from table where id = $userid"; $query = mssql_query($q); Link to comment https://forums.phpfreaks.com/topic/108579-posting-to-mysql-on-load-event/#findComment-556801 Share on other sites More sharing options...
jonsjava Posted June 3, 2008 Share Posted June 3, 2008 well, I'd recommend you do an insert query, not a select query, but, basically, yes. just don't do $query = mssql_query($q); do mssql_query($q); Oh, and didn't you say MySQL, not MSSQL? Link to comment https://forums.phpfreaks.com/topic/108579-posting-to-mysql-on-load-event/#findComment-556804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.