webmaster1 Posted November 27, 2008 Share Posted November 27, 2008 Hi All, (apologies for the fractional threads) I have a page (invalid.php) that basically echoes an error message. In the background I want to write the IP address and date to insert into a mySQL table every time the page loads rather than when a submit button is clicked. How would I trigger this based on the below snippet of code: $ipaddress = getenv('REMOTE_ADDR'); query = "INSERT INTO invalid VALUES ('','$ipaddress',NOW())"; mysql_query($query); Link to comment https://forums.phpfreaks.com/topic/134551-solved-inserting-values-into-mysql-on-page-load-rather-than-submit-button/ Share on other sites More sharing options...
trq Posted November 27, 2008 Share Posted November 27, 2008 Um, that snippet of code will do exactly what your asking for each time it is loaded. Link to comment https://forums.phpfreaks.com/topic/134551-solved-inserting-values-into-mysql-on-page-load-rather-than-submit-button/#findComment-700577 Share on other sites More sharing options...
Jahren Posted November 27, 2008 Share Posted November 27, 2008 <?php $ipaddress = getenv('REMOTE_ADDR'); query = "INSERT INTO invalid VALUES ('','$ipaddress',NOW())"; mysql_query($query); ?> <html> etc... Link to comment https://forums.phpfreaks.com/topic/134551-solved-inserting-values-into-mysql-on-page-load-rather-than-submit-button/#findComment-700579 Share on other sites More sharing options...
webmaster1 Posted November 27, 2008 Author Share Posted November 27, 2008 D'oh! Thanks guys. I always make the assumption that "nah, it could never be that simple." I geuess if theres no if condition and all the variables are attainable then it just does its thing. Link to comment https://forums.phpfreaks.com/topic/134551-solved-inserting-values-into-mysql-on-page-load-rather-than-submit-button/#findComment-700594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.