Nokelekele Nokelekele - 1 year ago 81
HTML Question

PHP check if not empty and the value of another GET

I have a POS and need to check 2 things before I save a sale in MySQL

Code to get and check the information I need


If invoice is empty the customer is also empty because is the first prodyct in this invoice so we assign a invoice number and we ask the customer to show identification, the invoice is generated automatic so we input the ID-number of the customer and save to MySQL

Now the problem

If the customer wants to buy 2 products we dont need to give the order a new invoice number neither the ID but we must check both in MySQL

code I am trying but not working

if( $invoice is empty && $customer is also empty)
{ we create new invoice an ask customer for id first time }
if( $invoice is empty && $customer is NOT empty)
{ we create new invoice but do not ask customer for id }
{ we use the $invoice and $customer comming from the form }

Any idea how to check that?

Answer Source

You should check that the $_POST values are actually set, first. I would guess that is where your error is coming from.

$invoice = (isset($POST['same_invoice']) ? $_POST['same_invoice'] : null;
$customer = (isset($POST['same_customer']) ? $_POST['customer'] : null;

if(empty($customer) || empty($invoice)) {
  //Use values from form
} else {
  //Create new invoice
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download