outboundadd.php 1.08 KB
Newer Older
Daniel Messer's avatar
Daniel Messer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
<?php

include 'creds.php';

$bin = $_POST['bin'];
$itemlistadd = $_POST['itemlistadd'];

// Check to makse sure bin is actually in use

$checkbin = mysqli_query($conn,"SELECT * FROM outbound WHERE bin = '$bin'");
$num_rows = mysqli_num_rows($checkbin);

if ($num_rows > 0) {
  goto Processing;
}
else {
  header("Location: error-binnotfound.html"); // Bin not found - send to error page
  exit;
}

Processing:
// Gather a count of total items entered

$text = $_POST['itemlistadd'];
$text = strip_tags($text);
// $text .= "\n";
$check = explode("\n", $text);
$lines = count($check);
$itemscount = ($lines - 1); // Total items entered

$getitemcount = mysqli_query($conn,"SELECT totalitems FROM outbound WHERE bin = '$bin'");
$itemscountorig = mysqli_fetch_row($getitemcount);

$newitemcount = ($itemscount + $itemscountorig[0]);


mysqli_query($conn, "UPDATE outbound SET itemlist = CONCAT(itemlist, '$itemlistadd') WHERE bin = '$bin'");
mysqli_query($conn, "UPDATE outbound SET totalitems = '$newitemcount' WHERE bin = '$bin'");

mysqli_close($conn);

header("Location: success-itemsadded.html");

?>