Jump to content

How to separate values from Array for saving in table.


theITvideos

Recommended Posts

Hey guys,

 

I need your help on this please.

 

I am working on a php web application. I have a form that gets information for Supplier and his traveling details.

 

The values are stored in arrays. I would like to store supplier details in Supplier table and the travelling details in the Travel table.

 

Here is the code with the comments.

 

<?php
    if (isset($_VARS['submitSuppliers']))
    {
        //error checking starts here
        $isError = false;
        if (empty($_VARS['supplierName']))
        {
            $isError = true;
            $_VARS['supplierRequest']['supplierName']['errorMessage'] = 'You need to provide a Supplier Name.';
        }

        if (empty($_VARS['address']))
        {
            $isError = true;
            $_VARS['supplierRequest']['address']['errorMessage'] = 'You need to provide an Address.';
        }
        if (empty($_VARS['travel']))
        {
            $isError = true;
            $_VARS['supplierRequest']['city']['errorMessage'] = 'You need to provide travelling details.';
        }

        #this checks if there is no error and then proceeds to save form values
        if (!$isError)
        {
            #This function adds the details and Returns the autoincremented Supplier ID
            $SupId = add_suppliers($_VARS); 
            if ($SupId)
            {
                #=== Now here I would like to save the travelling details in the Travel table  using the generated supplier id
                # $travId = add_Travel($_VARS); //==== how do I segregate only travel details from the $_VARS array to store in travel table?
                REDIRECT('/supplier/index.html', array('confirmationMessage' => 'Your details have been saved.'));
            }else
            {
                notify_admin('supplierjoin.php');
            }
        }else
        {
            $_VARS['supplierRequest']['errorMessage'] = "There was a problem with the information you provided. Please check the form and try again.";
        }
    }

?>

 

Kindly help.

 

Any comment or feedback is always welcome.

 

Thank you :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.