diff --git a/admin/functions.php b/admin/functions.php new file mode 100644 index 0000000..33c0008 --- /dev/null +++ b/admin/functions.php @@ -0,0 +1,129 @@ + $cat_title "; + } +} + +//getting Brands +function getBrands(){ + global $con; + $get_brands = "select * from brands"; + $run_brands = mysqli_query($con, $get_brands); + while ($row_brands= mysqli_fetch_array($run_brands)){ + $brand_id = $row_brands['brand_id']; + $brand_title = $row_brands['brand_title']; + echo "
  • $brand_title
  • "; + } +} + +function getPro($flag = ''){ + global $con; + $get_pro = ""; + if(!isset($_GET['cat']) && !isset($_GET['brand']) && !isset($_GET['search'])) { + if($flag == 'all_products') + $get_pro = "select * from products"; + else + $get_pro = "select * from products order by RAND() limit 0,6"; + } else if(isset($_GET['cat'])){ + $pro_cat_id = $_GET['cat']; + $get_pro = "select * from products where pro_cat = '$pro_cat_id'"; + } else if(isset($_GET['brand'])){ + $pro_brand_id = $_GET['brand']; + $get_pro = "select * from products where pro_brand = '$pro_brand_id'"; + } else if(isset($_GET['search'])){ + $search_query = $_GET['user_query']; + $get_pro = "select * from products where pro_keywords like '%$search_query%'"; + } + $run_pro = mysqli_query($con,$get_pro); + $count_pro = mysqli_num_rows($run_pro); + if($count_pro==0){ + echo "

    No Product found in selected criteria

    "; + } + while($row_pro = mysqli_fetch_array($run_pro)){ + $pro_id = $row_pro['pro_id']; + $pro_cat = $row_pro['pro_cat']; + $pro_brand = $row_pro['pro_brand']; + $pro_title = $row_pro['pro_title']; + $pro_price = $row_pro['pro_price']; + $pro_image = $row_pro['pro_image']; + echo " +
    +

    $pro_title

    + +

    Rs $pro_price/-

    + Details + +
    + "; + } +} +//getting the user IP address +function getIp() { + $ip = $_SERVER['REMOTE_ADDR']; + + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { + $ip = $_SERVER['HTTP_CLIENT_IP']; + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; + } + return $ip; +} +//creating the shopping cart +function cart(){ + if(isset($_GET['add_cart'])){ + global $con; + $ip = getIp(); + $pro_id = $_GET['add_cart']; + $check_pro = "select * from cart where ip_add = '$ip' AND p_id='$pro_id '"; + $run_check = mysqli_query($con,$check_pro); + if(mysqli_num_rows($run_check)>0){ + echo ""; + } else { + $insert_pro = "insert into cart (p_id, ip_add) VALUES + ('$pro_id','$ip')"; + $run_pro = mysqli_query($con,$insert_pro); + if($run_pro) + header('location:'.$_SERVER['PHP_SELF']); + } + } +} +//getting the total added items. +function total_items(){ + global $con; + $ip = getIp(); + $get_items = "select * from cart where ip_add='$ip'"; + $run_items = mysqli_query($con,$get_items); + $count_items = 0; + while($row = mysqli_fetch_array($run_items)) + $count_items += $row['qty']; + echo $count_items; +} +//getting the total price of the items in the cart +function total_price(){ + global $con; + $ip = getIp(); + $total = 0; + $sel_price = "select * from cart where ip_add = '$ip'"; + $run_price = mysqli_query($con,$sel_price); + while($cart_row = mysqli_fetch_array($run_price)){ + $pro_id = $cart_row['p_id']; + $pro_qty = $cart_row['qty']; + $pro_price = "select * from products where pro_id = '$pro_id'"; + $run_pro_price = mysqli_query($con, $pro_price); + while ($pro_row = mysqli_fetch_array($run_pro_price)){ + $pro_price = $pro_row['pro_price']; + $pro_price_all_items = $pro_price * $pro_qty; + $total += $pro_price_all_items; + } + } + echo 'Rs '.$total.'/-'; +} diff --git a/admin/index.php b/admin/index.php index 282da5b..b8ffd2e 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,5 +1,9 @@ @@ -33,28 +37,39 @@
  • - Insert New Category + + Insert New Category +
  • - View All Categories + + View All Categories +
  • - Insert New Brand + + Insert New Brand +
  • - View All Brands + + View All Brands
  • - View Customers + + View Customers
  • - View Orders + + View Orders
  • - View Payments + + View Payments
  • - Admin logout + + Admin logout
  • @@ -67,19 +82,52 @@
    +

    diff --git a/admin/insert_brand.php b/admin/insert_brand.php new file mode 100644 index 0000000..61b3ab2 --- /dev/null +++ b/admin/insert_brand.php @@ -0,0 +1,37 @@ + +
    +
    +
    +
    +

    Insert New Brand

    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + \ No newline at end of file diff --git a/admin/insert_category.php b/admin/insert_category.php new file mode 100644 index 0000000..50fc5e5 --- /dev/null +++ b/admin/insert_category.php @@ -0,0 +1,37 @@ + +
    +
    +
    +
    +

    Insert New Category

    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + \ No newline at end of file diff --git a/admin/insert_product.php b/admin/insert_product.php index d2d6beb..5dce0d5 100644 --- a/admin/insert_product.php +++ b/admin/insert_product.php @@ -1,3 +1,8 @@ +
    @@ -7,14 +12,15 @@
    - +
    +
    diff --git a/admin/login.php b/admin/login.php index 361575f..9b7058f 100644 --- a/admin/login.php +++ b/admin/login.php @@ -1,3 +1,29 @@ + @@ -11,13 +37,25 @@ Admin Login - + +

    +

    Admin Login

    - - - +
    + +
    +
    + + +
    + - \ No newline at end of file + + + + diff --git a/admin/view_brands.php b/admin/view_brands.php index dd3df9c..b760ebe 100644 --- a/admin/view_brands.php +++ b/admin/view_brands.php @@ -1,12 +1,43 @@ -

    Brands

    -
      - $brand_title"; - } - ?> -
    \ No newline at end of file + +
    +
    +

    Brands

    + + + + + + + + + + + + + + + + + +
    #NameActions
    + Edit + + + Delete + +
    +
    +
    \ No newline at end of file diff --git a/admin/view_categories.php b/admin/view_categories.php index c326a31..1c8625e 100644 --- a/admin/view_categories.php +++ b/admin/view_categories.php @@ -1,12 +1,43 @@ -

    Categories

    -
      $cat_title"; +if(!isset($_SESSION['user_email'])){ + header('location: login.php?not_admin=You are not Admin!'); } ?> -
    +
    +
    +

    Categories

    + + + + + + + + + + + + + + + + + +
    #NameActions
    + Edit + + + Delete + +
    +
    +
    \ No newline at end of file diff --git a/admin/view_customers.php b/admin/view_customers.php index c96822f..7287a3c 100644 --- a/admin/view_customers.php +++ b/admin/view_customers.php @@ -1,41 +1,52 @@ -

    Customers

    - -
    -
    + +
    +
    +

    Customers

    +
    + - - - - - - - + + + + + - - - - - - - - - - - "; - } - ?> - + + + No Customer found "; + } + else { + $i = 0; + while ($row_cust = mysqli_fetch_array($run_cust)) { + $cust_id = $row_cust['cust_id']; + $cust_name = $row_cust['cust_name']; + $cust_email = $row_cust['cust_email']; + $cust_image = $row_cust['cust_image']; + ?> + + + + + + + + + +
    NameEmailCountryCityContactAddressImage#NameEmailImageActions
    $cust_name$cust_email$cust_country$cust_city$cust_contact$cust_address
    + Delete + +
    - \ No newline at end of file +
    \ No newline at end of file diff --git a/admin/view_orders.php b/admin/view_orders.php new file mode 100644 index 0000000..6085cc0 --- /dev/null +++ b/admin/view_orders.php @@ -0,0 +1,7 @@ + +
    +
    +

    Products

    + + + + + + + + + + + + No Product found in selected criteria "; + } + else { + $i = 0; + while ($row_pro = mysqli_fetch_array($run_pro)) { + $pro_id = $row_pro['pro_id']; + $pro_cat = $row_pro['pro_cat']; + $pro_brand = $row_pro['pro_brand']; + $pro_title = $row_pro['pro_title']; + $pro_price = $row_pro['pro_price']; + $pro_image = $row_pro['pro_image']; + ?> + + + + + + + + + +
    #TitleImagePriceActions
    /- + Edit + + + Delete + +
    +
    +
    \ No newline at end of file