Yes the page posts to itself, the echoes I am talking about are the ones echoing the $_POST['ordersDateFrom'] variable. If i try to output any string in those echo they show correctly. The $_SESSION['ordersDateFrom'] = $_POST['ordersDateFrom']; and $_SESSION['ordersDateTo'] = $_POST['ordersDateTo']; is working so I have no idea why the $_POST variable are not recognized in the echo, nor in a possbile print_r($_POST, TRUE) statement (which i tried to include and it returns empty array). That just makes no sense.
when I echo $_SESSION['ordersDateFrom'] at the end of the page the new updated value is outputted!!
full page code:
<div class = 'boxHist'>
<?php
$itemsAddedAll = 0;
$amountAll = 0;
$results = $mysqli->query("SELECT * FROM orders");
while($row = $results->fetch_assoc()){
$itemsAddedAll += $row['qty'];
$costAll += $row['qty'] * $row['buyPrice'];
$amountAll += $row['qty'] * $row['price'];
}
?>
<table class = 'summary'>
<tr>
<td><h3><?php echo $xml->total_items_added; ?></h3></td>
<th><h2><?php echo $itemsAddedAll; ?></h2></th>
<td><h3><?php echo $xml->total_cost; ?></h3></td>
<th><h2>€ <?php echo number_format((float)$costAll, 2, ',', '.'); ?></h2></th>
<td><h3><?php echo $xml->total_amount; ?></h3></td>
<th><h2>€ <?php echo number_format((float)$amountAll, 2, ',', '.'); ?></h2></th>
</tr>
</table>
</div>
<div style = 'width: 200px;'>
<form method = 'POST'>
<?php echo $xml->from ?>: <script>DateInput('ordersDateFrom', true, 'YYYY-MM-DD')</script>
<?php echo $xml->to ?>: <script>DateInput('ordersDateTo', true, 'YYYY-MM-DD')</script>
<input type = 'submit' value = '<?php echo $xml->submit; ?>'>
</form>
</div>
<b><?php echo $xml->search_name; ?></b> <input type = 'text' onkeyup = 'filter("orders", value)'>
<span id = 'searchResults'>
<table class = 'results'>
<tr>
<th><?php echo $xml->date; ?></th>
<th><?php echo $xml->name; ?></th>
<th>TOT <?php echo $xml->buyPrice; ?></th>
<th>TOT <?php echo $xml->sellvalue; ?></th>
</tr>
<?php
$totalAll = 0;
$qtyAll = 0;
echo $_POST['ordersDateFrom'];
if(isset($_POST['ordersDateFrom']) && isset($_POST['ordersDateTo'])){
echo $_POST['ordersDateFrom'];
$_SESSION['ordersDateFrom'] = $_POST['ordersDateFrom'];
$_SESSION['ordersDateTo'] = $_POST['ordersDateTo'];
$results = $mysqli->query("SELECT * FROM orders WHERE (date BETWEEN '{$_POST['ordersDateFrom']}' AND '{$_POST['ordersDateTo']}')");
}
else{
echo $_POST['ordersDateFrom'];
$today = date("Y-m-d");
$results = $mysqli->query("SELECT * FROM orders WHERE date = '$today'");
}
while($row = $results->fetch_assoc()){
echo "<tr class='borderx'>";
echo "<td align='center'>{$row['date']} [{$row['time']}]</td>";
echo "<td align='center'><font color='blue'>".fetchRecord('item', 'name', $row['itemID'], $mysqli)." X ".$row['qty']."</font><font color='purple'> - ".$xml->buyPrice." €".$row['buyPrice']."</font><font color='green'> - ".$xml->sellvalue." €".$row['price']."</font></td>";
$total = $row['qty'] * $row['price'];
$totalCost = $row['qty'] * $row['buyPrice'];
echo "<td align='center'>€ ".number_format($totalCost, '2', ',', '.')."</td>";
echo "<td align='center'>€ ".number_format($total, '2', ',', '.')."</td>";
echo "</tr>";
$totalAll += $total;
$costTotalAll += $totalCost;
$qtyAll += $row['qty'];
}
echo "<tr>";
echo "<th colspan = '2'>".$xml->total_items_added." = $qtyAll</th>";
echo "<th>€ ".number_format($costTotalAll, '2', ',', '.')."</th>";
echo "<th>€ ".number_format($totalAll, '2', ',', '.')."</th>";
echo "</tr>";
?>
</table>
</span>
<?php if(isset($_SESSION['ordersDateFrom'])){echo $_SESSION['ordersDateFrom']." — ".$_SESSION['ordersDateTo'];} ?>
<!-- ACTIONS -->
<div id = 'popup'></div>