views:

34

answers:

3
$roidInfo = '';
$nomeDominio ='';
   if (isset($_GET['infoDominio']))
   {
     $nomeDominio = filter_input(INPUT_GET, 'nomeDominio', FILTER_SANITIZE_STRING);
     $dominioVo->setNome($nomeDominio);
     try 
     {
       ...
      $roidInfo = isset($infoDominio['roid']) ? $infoDominio['roid'] : '';
     }
     catch (EppCommandsExceptions $e)
     {
       ...
     } 

     //all well here, I get the dump with values:
     //var_dump($nomeDominio);
     //var_dump($roidInfo);
    }
    if (isset($_POST['atualizarDominio']))
    {
      var_dump($nomeDominio); //dump ""
      var_dump($roidInfo); //dump ""

On the above excerpt I lost the value of $nomeDominio and $roidInfo but I don't understand why. Can I have your help to find out why is this happening?

UPDATE

Here is, the exact same issue, but by using SESSIONS:

<?php session_start(); ?>

<?php
 $roidInfo = '';
 $nomeDominio ='';

 if (isset($_GET['infoDominio']))
 {
    $nomeDominio = '123';
    try 
    {
      //...
      $roidInfo = '456';

      $_SESSION['nomeDominio'] = $nomeDominio;
      $_SESSION['roidInfo'] = $roidInfo;

      //retrieving the values. OK.
      var_dump($_SESSION['roidInfo']);
      var_dump($_SESSION['nomeDominio']);
     }
     catch (EppCommandsExceptions $e)
     {
       //...
     }
 }

 if (isset($_POST['atualizarDominio']))
 {
    //retrieving index undefined. not ok.
    var_dump($_SESSION['nomeDominio']);
    var_dump($_SESSION['roidInfo']);


    //all the rest... runs
 }

?>

Thanks in advance, MEM

A: 

Is isset($_GET['infoDominio'] actually true? If thats not the case $nomeDominio stays an empty string in the last code block.

softcr
? Yes, isset($_GET['infoDominio'] is true, all that is inside runs, and it only runs if it's true, so it's, it's true. Still, I have dump it: bool(true). So yes. All true.
MEM
A: 

You got two DIFFERENT conditions. one on $_GET['infoDominio'], one on $_POST['atualizarDominio']. Maybe only one of them is set and the other is not?

The "all well" code is run when $_GET['infoDominio'] is set. The "not all well" is run when $_POST['atualizarDominio'] is set. They are two different variables!

edit:

OK, as I found in the discussion under the original original question - the real issue is that PHP doesn't remember $nomeDominio and $roidInfo between each run of the script - you have to use sessions or cookies to remember them.

Karel Bílek
@Karel Bilek - What do you suggest in order to prove your assumption? What do I need to test here in order to see if what you are saying is true? Thanks in advance.
MEM
I edited the answer to the actual issue (if I got it right) from the discussion up there
Karel Bílek
I've used sessions I still get those values undefined. :( Not been that, what could it be?
MEM
A: 

This was a weird case. I was able do pass the values due to my form action declarations.

I had, on the first form:

 <form name="infoDominio" action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>"  method="get">

On the second form:

<form action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" name="atualizarDominio" method="post">

If we remove the action information from the second form:

<form action="" name="atualizarDominio" method="post">

It will work.

Thank you all that have replied, this is, à mon avis, a weird stuff. :s

MEM