Jump to content

Recommended Posts

Hi

I'm a bit stuck on this and would really appreciate some help! :)

The visitor comes to the site via a 'personalised' value - http://www.mysite.com/?384

as I would like to be able to 'track' the user using this value  (348) so need to extract this data for later.

 

I am able to print out the /?384 part using $REQUEST_URL, but when I try and write it to a log file (or send using the mail() function) it doesnt' seem to work.

 

The code I'm using for writing to log is simply:

	$entry_line = "Username: $username | ID: $REQUEST_URL \n";
	$fp = fopen('logs.txt', 'a');
	fputs($fp, $entry_line);
	fclose($fp);

 

I also tried defining:

$number = str_replace("/?", "", $REQUEST_URL);

to see if I could just log the variable $number, but to no avail as it remains blank.

 

Thanks in advance for any help! :D

 

 

Link to comment
https://forums.phpfreaks.com/topic/65436-solved-extract-data-from-url/
Share on other sites

With that URL you suggested, 384 will be a key in the $_GET array. If that will always be the only value passed in the URL you can get it by iterating pretty easy, if there will be more values, you can return all the keys with array_keys. The whole process would be a lot simpler, though, if you put a name for the value being passed like, http://mysite.com/?n=384. Then it is as simple as $_GET['n']. But, whatever works for you.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.