Пример #1
0
<?php

/**
 * Created by PhpStorm.
 * User: Radley
 * Date: 12/3/2015
 * Time: 6:19 PM
 */
require 'connect.php';
$is_gain = $_GET['is_gain'];
// bill name/type todo add me
$bill_name = $_GET['bill_name'];
// bill name/type todo change me from bill type
$frequency = $_GET['frequency'];
// how often todo SINGLE WEEKLY BI-WEEKLY MONTHLY
$due_period = $_GET['due_period'];
// how often todo enum('eom','bom')
$every_x_days = $_GET['every_x_days'];
// how often todo int add me
$on_the_x = $_GET['on_the_x'];
// how often todo int add me
$amount = $_GET['amount'];
// dollar amount
$user_id = SignUserIn('radley', 'radley123');
echo $user_id;
if (SignUserIn('radley', 'radley123') != 0) {
    $gain = $is_gain === true;
    echo $gain;
    $added_bill = AddBill(1, $is_gain, $bill_name, $frequency, $due_period, $every_x_days, $on_the_x, $amount);
} else {
}
Пример #2
0
 public function updateBill($username, $userpass)
 {
     // create the connection to the DB
     $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     // create message array to be used as JSON
     $message = array();
     $is_there = '';
     // get the users_id
     $user_id = SignUserIn($username, $userpass);
     if ($user_id != 0) {
         // check to see if the bill_id is null exists
         if (isset($this->bill_id)) {
             // check to see if the bill_id exists
             //check to see if the bill_id exists
             $sql1 = "SELECT * FROM UserBills WHERE bill_id = '{$this->bill_id}'";
             $result = $conn->query($sql1);
             if ($result->num_rows > 0) {
                 $is_there = 1;
                 // true
             } else {
                 $is_there = 0;
                 // false
             }
         } else {
             $message['success'] = 'false';
             $message['message'] = 'bill id was not sent!';
         }
         //if the bill exists in the DB update it
         if ($is_there) {
             $rows_updated = 0;
             // keep count of updated cells
             $rows_not_updated = 0;
             // keep count of cells that did not update
             if (isset($this->is_gain)) {
                 $sql = "UPDATE UserBills SET is_gain = '{$this->is_gain}' WHERE bill_id = '{$this->bill_id}'";
                 if ($conn->query($sql) === TRUE) {
                     $rows_updated += 1;
                 } else {
                     $rows_not_updated += 1;
                 }
             }
             if (isset($this->bill_name)) {
                 $sql = "UPDATE UserBills SET bill_name = '{$this->bill_name}' WHERE bill_id = '{$this->bill_id}'";
                 if ($conn->query($sql) === TRUE) {
                     $rows_updated += 1;
                 } else {
                     $rows_not_updated += 1;
                 }
             }
             if (isset($this->frequency)) {
                 $sql = "UPDATE UserBills SET frequency = '{$this->frequency}' WHERE bill_id = '{$this->bill_id}'";
                 if ($conn->query($sql) === TRUE) {
                     $rows_updated += 1;
                 } else {
                     $rows_not_updated += 1;
                 }
             }
             if (isset($this->due_period)) {
                 $sql = "UPDATE UserBills SET due_period= '{$this->due_period}' WHERE bill_id = '{$this->bill_id}'";
                 if ($conn->query($sql) === TRUE) {
                     $rows_updated += 1;
                 } else {
                     $rows_not_updated += 1;
                 }
             }
             if (isset($this->every_x_days)) {
                 $sql = "UPDATE UserBills SET every_x_days = '{$this->every_x_days}' WHERE bill_id = '{$this->bill_id}'";
                 if ($conn->query($sql) === TRUE) {
                     $rows_updated += 1;
                 } else {
                     $rows_not_updated += 1;
                 }
             }
             if (isset($this->on_the_x)) {
                 $sql = "UPDATE UserBills SET on_the_x = '{$this->on_the_x}' WHERE bill_id = '{$this->bill_id}'";
                 if ($conn->query($sql) === TRUE) {
                     $rows_updated += 1;
                 } else {
                     $rows_not_updated .= 1;
                 }
             }
             if (isset($this->amount)) {
                 $sql = "UPDATE UserBills SET amount = '{$this->amount}' WHERE bill_id = '{$this->bill_id}'";
                 if ($conn->query($sql) === TRUE) {
                     $rows_updated += 1;
                 } else {
                     $rows_not_updated += 1;
                 }
             }
             $message['success'] = 'true';
             $message['message'] = 'the number of cells updated: ' . $rows_updated . '. the number of rows that failed: ' . $rows_not_updated . '.';
         } else {
             $message['is_there'] = 'false';
         }
     } else {
         $message['success'] = 'false';
         $message['message'] = 'Logging in failed user id:' . $user_id . 'username: '******'userpass: ' . $userpass;
     }
     return json_encode($message);
 }