Page 1 of 1
[RESOLVED]Passing URL vars ?
Posted: Sun Dec 20, 2009 12:16 pm
by voxberry
Hello .
I'm working on a function that displays some data from mysql .
so at some point I need to get a var from the url :
http://www.site.com/index.php?page=home&[b]somevar[/b]=somedata
I can use $_GET['
somevar'];
but I think I'm doing it wrong .
I found that smarty should work with this : $smarty.get.
somevar . but it does not work for me .
any help on passing url vars ?
Re: Passing URL vars ?
Posted: Sun Dec 20, 2009 5:59 pm
by jmcgin51
this is not a CMSMS question. Any PHP tutorial site will explain this. I like
www.w3schools.com/php
Re: Passing URL vars ?
Posted: Sun Dec 20, 2009 6:13 pm
by voxberry
well ... I think it is a CMSMS question as it does use SMARTY ... and I was trying to learn how to get vars from the url as CMSMS does ...
I was not asking for a basic php method to read the vars from the url . (like $var = $_GET['var']; / $var = $_POST['var']
I was asking how one would do that INSIDE CMSMS, maybe using the SMARTY engine .
Re: Passing URL vars ?
Posted: Sun Dec 20, 2009 9:43 pm
by dipper88
I too had the same problem and solved it the following way
Code: Select all
{php}
$this->assign('var',$_GET['var']);
{/php}
There might be some way to have the code look more uniform, but at least this one's working
Re: Passing URL vars ?
Posted: Sun Dec 20, 2009 10:20 pm
by voxberry
well.... something like that .
only I'm looking to do this inside a /function.dblist.php file, and $this->assign('var',$_GET['var']); does not work outside content .
anyway .. yup, i'm looking for something like that .
My main problem is that using simple $_GET would be vurnerable and I was thinking that i can somehow use smarty for a safer var passing .
thanks anyway . anymore input on this is welcomed .
Re: Passing URL vars ?
Posted: Sun Dec 20, 2009 10:29 pm
by voxberry
well....
i donno how I made this work and I still donno how good it works, but here is what works for me :
$smarty->assign('VAR',$_GET['VAR']);
$VAR= $smarty->get_template_vars('VAR');
and I think with pretty urls the security problem is less of a problem .