Problem with php POST Variable

Asked

Viewed 190 times

0

Code:

Form:

<form action="../controller/NotPrecontrole.php" method="POST" onsubmit="return valid();">
   <input type="hidden" name="id" value="<?php echo $id; ?>"/>
   <input type="date" name="DtInicio" value="<?php echo $DtInicio; ?>">
   <input type="submit" class="round success small button" value="Aplicar"/>
   <a class="round secondary small button" href="Home.php">Voltar</a>
</form>

Precontrol:

$id = $_POST['id'];
$DsMsg = $_POST['Msg'];
$InAtivo = $_POST['InAtivo'];
$DtInicio = $_POST['DtInicio'];
$DtFim = $_POST['DtFim'];

$objNot = new Not();
$objNot->setid($id);
$objNot->setmsg($DsMsg);
$objNot->setativo($InAtivo);
$objNot->setini($DtInicio);
$objNot->setfim($DtFim);

$controller = new Notifica($conn);


if (!empty($id)){
   $objNot->setid($id);
   $controller->editarNot($objNot);
}

header ("location: ../view/home.php?id=".$id);

Home:

 <?php 
 foreach ($controller->ListaNot() as $objNot){
         echo '<li><a href="editNot.php?id=' . $objNot->getid() . '">Editar</a></li>';

    if($DtInicio == date('Y-m-d')){
      echo $objNot->getmsg(); 
   } 
}

Error:

Notice: Undefined variable: Dtinicio in C: xampp htdocs Rasador1 view home.php on line 63

I’m trying to get the date that goes to the POST on $DtInicio and compare with today’s date to print on screen $objNot->getmsg();, but is giving the error above. I need to give a Isset and take her for GETbut don’t know how, some help ?

  • You are giving a header("Location"), this I believe does not leave the value of the variable $Dtinicio anymore. Because it doesn’t pass as parameter like it does with id? It would be header ("Location: ../view/home.php?id=".$id."&data=".$Dtinicio); then get it with $_GET. I didn’t have time to test it.

  • Post the HTML form

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.