Page 1 of 1

If Then stuff...

Posted: Fri Nov 06, 2009 11:15 am
by marcusreed
I am very new to coding and I am wanting to build an expense program. I have 5 database tables consisting of Expenses, Gas, Service, Tolls, and General. The Expenses table has a primary key of ExpenseID and also an ExpenseCategory field which is ENUM('Gas','Service','Tolls','General') . The other 4 tables also have an ExpenseID field. What I would like to happen, is that when a user went to "CREATE EXPENSE", they would be brought to a specific insert record page for the category they are creating the expense for and the new ExpenseID would be passed into a hidden form field. How would I go about doing this?

Here is the code that I would like to modify with an if/then:

Code: Select all

$insertGoTo = "test.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
So if the form field being submitted equals "Gas" then $insertGoTo = "gas_insert.php";