exec($createQuery); if (!$db->exec($createQuery)) { die("Failed to create the 'projects' table."); } $db->close(); } else { $db = new SQLite3($dbFile); if (!$db) { die("Database connection failed: " . $db->lastErrorMsg()); } } if ($_SERVER["REQUEST_METHOD"] == "POST") { $projectname = $_POST["projectname"]; if (strpos($projectname, '&') !== false) { // echo "The string contains an ampersand (&)."; $projectname = str_replace('&', '-LBR', $projectname); } if (strpos($projectname, '
') !== false) { $projectname = preg_replace('//i', '', $projectname); } $erfno = $_POST["erfno"]; $allotment = $_POST["allotment"]; $client = $_POST["client"]; // Set the time zone to your desired time zone date_default_timezone_set('Africa/Johannesburg'); // Get the current date and time $currentDateTime = date('Y-m-d H:i'); $clientprogress = $currentDateTime; $db2 = new SQLite3('database/clients.db'); // Fetch data from the 'clients' table $query2 = "SELECT name, id FROM clients"; $result2 = $db2->query($query2); // Populate the dropdown with data while ($row2 = $result2->fetchArray()) { if ($row2['name'] == $client) { $clientid = $row2['id']; } } // Close the database connection $db2->close(); // Connect to the SQLite database $db = new SQLite3('database/projects.db'); // Prepare and execute the INSERT query to add the client to the database $insertQuery = "INSERT INTO projects (projectname, erfno, allotment, client, clientid, clientprogress) VALUES ('$projectname', '$erfno', '$allotment', '$client', $clientid, '$clientprogress')"; $db->exec($insertQuery); // Close the database connection $db->close(); // Redirect to the ClientList.php page after adding the client header("Location: https://blackhoundenterprises.com/invoices/projects.php"); exit; } ?> Create Project

Create a New Project