Jump to content

4E20

New Members
  • Posts

    5
  • Joined

  • Last visited

4E20's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I changed the the method from $_POST to $_GET and all works perfectly. This does not give me a solution to why it didn't work with $_POST but got me around the problem. Thank all.
  2. This is the only form in the page, and as I wrote in first post, through firebug console I can see and confirm that the variable are correctly passed with correct name and value, infact the $_SESSION variables do get updated.
  3. 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>
  4. I have tried that, the array results empty. As I wrote before through the firebug console the $_POST variable are correctly seen and posted. The strangest part of all this is that the $_session variables are updated with the $_POST values o.O I am double checking if any of the statements mentioned above are called after the form is sent. I'll post more code asap. here is the code with the form <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 "<pre>" . print_r($_POST, TRUE) . "</pre>"; 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'"); }
  5. Hello people, I am writing this post because since last night im getting a really weird problem with a $_POST form. I will not paste the actual form code since the values are generated by a javascript calendar, but I will paste the code where the values are retrieved and the weird problem is found. The $_POST values are properly sent and are correctly viewed in firebug console, with the right names/values. 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'"); } Ok so, the problem is that none of the echo of the $_POST variables are outputted, and the query is always the one with $today so its obvious the variables are not recognized in the If statement, but.....both the $_SESSION variables update with the $_POST values!! This just makes no sense. Any help appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.