Skip to content

Commit

Permalink
Fix error reporting and include admin password check in new_product.php
Browse files Browse the repository at this point in the history
  • Loading branch information
judemont committed Oct 13, 2024
1 parent ea8f6c6 commit 2ccf957
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions api/new_product.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
include_once(dirname(__FILE__) . "/utils/database.php");
include_once(dirname(__FILE__). "/secrets/database.php");
include_once(dirname(__FILE__). "/utils/secrets.php");

$db = new Database;
const ALLOWED_IMAGES_EXT = ["png", "jpg", "jpeg"];
const ALLOWED_IMAGES_MIMES = array("image/jpeg", "image/png");
const MAX_IMAGES_SIZE = 2 * 1000 * 1000; // 2 MB

$password = $_POST["password"];
echo $password;
echo ADMIN_PASSWORD;
if($password != ADMIN_PASSWORD) {
echo json_encode(array("error"=> "invalid admin password"));
exit();
Expand Down
2 changes: 1 addition & 1 deletion api/utils/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Database
public function __construct()
{
include_once(dirname(__FILE__) . "/secrets.php");
$this->conn = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
$this->conn = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME, DB_HOST_PORT);

if ($this->conn->connect_error) {
die("Connection failed: " . $this->conn->connect_error);
Expand Down
2 changes: 1 addition & 1 deletion new_product/new_product.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function onFormSubmit() {
const specificationsValuesInputs = document.getElementsByClassName("specificationValueInput")
const specificationsTitlesInputs = document.getElementsByClassName("specificationTitleInput")

if(specificationsTitlesInputs[i].value != "" && specificationsValuesInputs.value != ""){
if(specificationsTitlesInputs.value != "" && specificationsValuesInputs.value != ""){
let result = [];

for (let i = 0; i < specificationsTitlesInputs.length; i++) {
Expand Down

0 comments on commit 2ccf957

Please sign in to comment.