You are here: Re: [PHP] url reload « PHP « IT news, forums, messages
Re: [PHP] url reload

Posted by "Richard Lynch" on 07/11/05 12:26

On Thu, July 7, 2005 6:40 pm, timothy johnson said:
> This should be pretty simple but I cant find any info on it at the
> site. I am writing a function that will create a anchor, but I want it
> to call the same page it is on. Is there a way to get the current php
> page I am on so that when I output my anchor for that correct page.
>
> so if I call it from index.php the link will say:
> index.php?var=data
>
> but if I can the same function from say photos.php then the link would be:
> photos.php?var=data......

It's pretty rare that you REALLY want to blindly copy ALL $_GET arguments,
but you can:

$get = '';
reset($_GET);
while (list($k, $v) = each($_GET)){
$get .= "&k=" . urlencode($v);
}
$get[0] = '?';


But you should *PROBABLY* be checking for specific values in $_GET, making
sure they are "clean" and passing on only those values.

$kosher = '[^A-Za-z0-9\'"\\. ,-]';
$name = $_GET['name'];
$zip = $_GET['zip'];
$zip = (int) $zip; //Assuming only 5-digit zip code will ever be used in
this application
$zip = sprintf("%05s", $zip);
$name = preg_replace($kosher, '', $name);
$url = "?name=" . urlencode($name) . "&zip=$zip";

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация