0

I am trying to run a simple select on the DB from a HTML form

HTML snippet is

<form Name ="form1" Method ="post" ACTION = "get341Usage.php">

<input type="submit" name="Submit1" value="3 Months" >

</form>

PHP file get341Usage.php

<?php
function get341Usage($org_id,$usage_mnth ) {

  $conn = oci_connect('user', 'pass', '//server/ora_instance');

  $query = "SELECT usage.* from usage_table usage 
  where customer_number            = ' . $cust_id . '
  AND usage_date >= (select add_months(sysdate ,' . $usage_mnth . '))";

  $stid = oci_parse($conn, $qryStr);
  oci_execute($stid);


  oci_free_statement($stid);


}

if(isset($_POST['submit']))
{
    getUsage($org_id,$usage_mnth);
} 

?>

the reason for the 2 paramters was I wanted to create 3 buttons 3,6,12 monnths where the user to clicks and it prompts to auto save teh data to a csv file (haven't even got to this pary yet!)

any points would be great ...I suspect I'm miles off

  • 3
    First, the name of you submit button is `Submit1` so check for `isset($_POST['Submit1'])`. Second, your function name isn't called `getUsage` but `get342Usage`. Third, 2 undefined variables `$org_id` and `$usage_mnth` – Daan Feb 03 '16 at 13:36
  • firstly thanks for hte reply , first time poster , and didn't find a good answer that fit for me . I relation to your points I changed alot of the names to add a generic mode to the script as there was some business sensitive data in there the function is call get341Usage through out, the undefined variables are defined by 1 global function which calls the $org_id(cust_id) and 2 a html form for $usage_mnth. – Marc McElhinney Feb 03 '16 at 17:13

1 Answers1

0
if(isset($_POST['Submit1']))
{
    getUsage($org_id,$usage_mnth);
}
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
neet.world
  • 11
  • 2
  • 2
    Why should the OP try this? A ***good answer*** will always have an explanation of what was done and why it was done that way, not only for the OP but for future visitors to SO. In addition, there are several other issues with the OP's code. – Jay Blanchard Feb 03 '16 at 13:45
  • thanx for explanation – neet.world Feb 04 '16 at 06:23