Hi,
I have certain links in one page.
<?
echo "<a href=\" /myYii/index.php?r=login/post?var=link 1\">Link 1 </a>";
echo "<a href=\" /myYii/index.php?r=login/post?var=link 2\">Link 2 </a>";
echo "<a href=\" /myYii/index.php?r=login/post?var=link 3\">Link 3 </a>";
?>
if i click any of the links it has to go the post.php.
And in that page i have to retrieve the value of the variable "var".
But when i run it, its showing the error
" The system is unable to find the requested action "post?var=link 1".
I tried it with normal WAMP. Its Working.
What to do if i want to pass the value via the URL in Yii. Anyone please help me…
junxiong
(Garry3peace)
2
Do you have LoginController class with a actionPost($var) as its method??
You may post your code of LoginController first to avoid misunderstand~
LoginController.php
public function actionPost($var)
{
$this->render("post");
}
i have tried this too. but its not working. can u help me how to use it?
LoginController.php
public function actionPost($var)
{
$this->render("post");
}
i have tried this too. but its not working. can u help me how to use it?
The problem is in ur link tags
it should be &var= NOT ?var=
<?
echo "<a href=\" /myYii/index.php?r=login/post&var=link-1\">Link 1 </a>";
echo "<a href=\" /myYii/index.php?r=login/post&var=link-2\">Link 2 </a>";
echo "<a href=\" /myYii/index.php?r=login/post&var=link-3\">Link 3 </a>";
?>
junxiong
(Garry3peace)
6
ah yes Anupam is right. I’ve failed to notice the URL…
Hi anupam,junxiong
Thank u for your replies.Its working perfectly. Thanks a lot.
One more doubt,
If i want to pass more than one values, how can i do that? Please help me…
junxiong
(Garry3peace)
8
Then it should be
<a href=\" /myYii/index.php?r=login/post&var=link-1&var2=value2&var3=value3\">Link 1 </a>
and your controller just write
function actionPost($var, $var2, $var3){
}
jkofsky
(Jkofsky)
9
I think you could also use:
echo CHtml::link('Link 1', array('login/post', 'var'=>'link-1','var2'=>'value2',...));
I think that using this syntax var COULD be ‘link 1’ that would encode to ‘link%201’.
%20=space.
Just tring to help