jpfred Posted February 6, 2007 Share Posted February 6, 2007 I have been reading several PHP books and have yet to find out how to capture the users url. I would imagine that there exitst a session variable/value that can be captured into a variable. Anybody have a idea to set me in the right direction? Quote Link to comment Share on other sites More sharing options...
fert Posted February 6, 2007 Share Posted February 6, 2007 I'm not sure if you mean $_SERVER['HTTP_REFERER'] or $_SERVER['PHP_SELF'] Quote Link to comment Share on other sites More sharing options...
jpfred Posted February 6, 2007 Author Share Posted February 6, 2007 To clarify what I am trying to do, When an individual executes to myfile.php by clicking on SUBMIT on myfile.html I would like to be able to capture their current ip address or complete url and write it to a database. A conceptual example of what I would like can be seen below: <?php $myip=??????; mysql_connect("myserver.myserver.com", "myuserid", "mypassword") or die(mysql_error()); mysql_select_db("mydatabase") or die(mysql_error()); $data = mysql_query("INSERT INTO mytable VALUES($myip)"); ?> Expected result would be: $myip = 11.11.11.11 The part I am confused about is what would I need to fill in "??????" Quote Link to comment Share on other sites More sharing options...
PunjabHaker Posted February 6, 2007 Share Posted February 6, 2007 $myip = getenv("REMOTE_ADDR"); that ? Quote Link to comment Share on other sites More sharing options...
jpfred Posted February 7, 2007 Author Share Posted February 7, 2007 That did the trick, Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.