I'm french, so apologize for my English. I've some troubles in my zend application with variables in URLs. I'm creating a back-office application for Hotel's services.
Explication :
I've to set a table with user's information like "id, name, first name etc..." The admin can delete some users when he clicks on "delete" button.
Because i'm a new ZF user, I learned how to send variables from "views" to "controllers"
My views :
I've set the variable transfer with this command.
<?php echo $this->url(array('controller'=>'moderation','action'=>'supprimer' , 'id' => $donnees['id']));?>">
It's works fine, my variables is in my "supprimerAction", it's cool. My URL is like localhost/moderation/supprimer/id/2
BUT, just after, when i'm clicking in another link, to change the controller, my variables are STILL in my URL like localhost/welcome/id/2
i don't know why...
To resolve this problem, I've created another new page, with another controller etc...etc..., it's the same things. My variables are still showed in my url...
I don't know if you understand what my problem is but i worked on it since 2 days...
My codes :
Moderation.phtml
while ($donnees = $this->reponse->fetch())
{
if ($donnees['hotel_zone'] == 0)
$donnees['hotel_zone'] = "Paris";
else
$donnees['hotel_zone'] = "Province";
?>
<tr>
<td style="border-top:1px solid grey"> <?php echo $donnees['id'];?></td>
<td style="border-top:1px solid grey"> <?php echo $donnees['hotel_name'];?></td>
<td style="border-top:1px solid grey" ><?php echo $donnees['id_availpro'];?></td>
<td style="border-top:1px solid grey" ><?php echo $donnees['c_name'];?></td>
<td style="border-top:1px solid grey" ><?php echo $donnees['c_email'];?></td>
<td style="border-top:1px solid grey" ><?php echo $donnees['c_url'];?></td>
<td style="border-top:1px solid grey" ><img src="<?php echo $this->baseUrl;?>/public/css/yes.gif"></td>
<td style="border-top:1px solid grey" ><a href="<?php echo $this->url(array('controller'=>'moderation','action'=>'supprimer' , 'id' => $donnees['id']));?>"><img src="/public/img/no.png"></a>
</tr><?php
}
ModerationController :
<?php
class ModerationController extends Zend_Controller_Action
{
/*function init(){ $this->view->baseUrl = $this->_request->getBaseUrl(); }*/
function indexAction()
{
//echo $this->getRequest()->getParam('id');
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=myloocalhost;dbname=fhg_bo', 'root', '', $pdo_options);
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
$this->view->reponse = $bdd->query('SELECT id, hotel_name, hotel_city, hotel_zone, c_title, c_name, c_fname, id_availpro, c_email, c_phone, c_url FROM nouveau_client');
$this->view->nb_mod = $bdd->query('SELECT COUNT(*) FROM nouveau_client GROUP BY id');
}
function supprimerAction ()
{
echo $this->getRequest()->getParam('id');
}
}
?>
So when i'm receiving this variables and when i'm clicking on another link, my variables are still in my url... It's like variables are memorized in my program....
Thanks for helping me,
And again, sorry for my English, i'll do my best for answering questions.
Thanks