kproc
08-24-2006, 03:08 PM
Hi
is there a way that I can get a pages url and assign it to a variable using php
is there a way that I can get a pages url and assign it to a variable using php
|
Click to See Complete Forum and Search --> : php request url kproc 08-24-2006, 03:08 PM Hi is there a way that I can get a pages url and assign it to a variable using php The Little Guy 08-24-2006, 03:15 PM Example URL: http://example.com/index.php?page=mypage $myvariable = $_GET['page']; $myvariable now contains mypage Or do you want the entire URL? kproc 08-24-2006, 03:17 PM yes I know how to do that but I want to get everything before the ? The Little Guy 08-24-2006, 03:20 PM do you want the current page? or a page from somewhere else? If you want the current page: echo $_SERVER['PHP_SELF']; $val = $_SERVER['PHP_SELF']; kproc 08-24-2006, 03:28 PM Thank you for the info, I gave it a try and did not work. I have a calendar that offers each day of the week as link. I want to offer a calendar icon for the user to click which will popup the calendar and when the user clicks a date it files a forms text field with the date. I'm thinking that I would have to make the begining url a variable as I only want to have to create one calendar and At the end of the webpage address I was set a variable like ?id=$id then set the form field to request the id NogDog 08-24-2006, 03:32 PM Probably the most dependable way would be something like: $thisPageUrl = 'http://www.mydomain.com'.array_shift(explode('?', $_SERVER['PHP_SELF'])); If you want to include any query string as well, then get rid of the array_shift/explode stuff, but be aware that users could manually add anything to the query string, so you'll need to screen it for anything you don't want to be output (htmlspecialchars(), perhaps?). The Little Guy 08-24-2006, 03:48 PM Try this: echo "http://mysite.com".$_SERVER['PHP_SELF']; why don't you just have a URL that looks like this: http://mysite.com/page.php?month=8&day=24&year=2006 It will be one URL, where you could get the month day and year, and then do what you want using $_GET kproc 08-24-2006, 04:14 PM I have it working so that the url show the page were I I want the value to go. I ran into a snag. A window with a calendar is opened via a pop-up from an icon next to the field were I want the information to go. The prblem is when I click the date I need it to send the value to the form field. thank you for the help bokeh 08-24-2006, 04:22 PM Probably the most dependable way would be something like: $thisPageUrl = 'http://www.mydomain.com'.array_shift(explode('?', $_SERVER['PHP_SELF'])); If you want to include any query string as well, then get rid of the array_shift/explode stuff, but be aware that users could manually add anything to the query string, so you'll need to screen it for anything you don't want to be output (htmlspecialchars(), perhaps?).$_SERVER['PHP_SELF'] shouldn't contain the query string if one were to exist. kproc 08-24-2006, 04:30 PM The calendar is a seperate page which is opened via javascript. the dates are hyperlinks which when licked I want the value written to the form So if user clicks 24 the value 08-24-2006 which is stored in id would be entered into a form on the active page. just like if I click a smile it sends the code to my post equals :) webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |