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? Link to comment https://forums.phpfreaks.com/topic/37239-solved-capturing-the-incoming-url/ 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'] Link to comment https://forums.phpfreaks.com/topic/37239-solved-capturing-the-incoming-url/#findComment-177880 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 "??????" Link to comment https://forums.phpfreaks.com/topic/37239-solved-capturing-the-incoming-url/#findComment-178086 Share on other sites More sharing options...
PunjabHaker Posted February 6, 2007 Share Posted February 6, 2007 $myip = getenv("REMOTE_ADDR"); that ? Link to comment https://forums.phpfreaks.com/topic/37239-solved-capturing-the-incoming-url/#findComment-178088 Share on other sites More sharing options...
jpfred Posted February 7, 2007 Author Share Posted February 7, 2007 That did the trick, Thanks! Link to comment https://forums.phpfreaks.com/topic/37239-solved-capturing-the-incoming-url/#findComment-178738 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.