<?php require_once "Includes/db.php"; $result = TenantDB::getInstance()->add_new_building("'" . $_POST['buildName'] . "'", "'" . $_POST['buildAddress'] . "'"); if (!$result) { printf("Error: %s\n", mysqli_error(TenantDB::getInstance())); exit; } header('Location: buildings.php');
public function add_new_tenant($leaseId, $fname, $lname, $ssn, $address, $email, $phone) { $result1 = $this->query("INSERT INTO tenant (tenant_id, first_name,last_name,ssn,current_address,email,phone) VALUES \n (NULL," . $fname . ", " . $lname . ", " . $ssn . ", " . $address . ", " . $email . ", " . $phone . ")"); if (!$result1) { printf("Error: %s\n", mysqli_error(TenantDB::getInstance())); exit; } $result2 = $this->query("SELECT MAX(tenant_id) FROM tenant"); $row = mysqli_fetch_array($result2); $tenantId = $row[0]; $result3 = $this->query("INSERT INTO lease_tenant (TENANT_ID,LEASE_ID) VALUES \n (" . $tenantId . ", " . $leaseId . ")"); return $result1 && $result2 && $result3; }