passer une variable d'un page a l'autre
Bonsoir,
je voudrai passer une variable d'un page à l'autre, seulement sa ne marche pas, comment faut il proceder ??
Merci.
Le formulaire
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<body>
<p align="center">Envoi</p>
<form method="post" action="compteur-edf-mysql-modifier-hc-2.php" >
<div align="center">
<div align="center">
<table width="auto" border="1">
<tr>
<th scope="col">Date ( Format date aaaa-mm-jj )</th>
<th scope="col"><input type="hidden" name="id" value="" /><input type="text" name="date-auto" size="7" maxlength="10" value="" /></th>
</tr>
<tr>
<th scope="row"> </th>
<td> </td>
</tr>
<tr>
<th colspan="2" scope="row"><input type="submit" name="envoyer" value="Modifier" /></form></th>
</tr>
</table> |
La page ou est envoyée la variable
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
<?php
/* ------ DATE ----------- */
$bouton = $_POST['Modifier'];
if(!empty($bouton)) {
$id = trim($_POST['id']);
$date_automatique = trim($_POST['date-auto']);
if(!empty($id) && !empty($date_automatique)) {
echo 'affiche les variables : '.$id.' '.$date_automatique;
}
else
{
echo 'vous n\'avez pas rempli le champ : Date';
}
}
?> |