-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert_product.php
158 lines (144 loc) · 6.85 KB
/
insert_product.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
$con = mysqli_connect("localhost", "root", "", "minor2");
session_start();
$userprofile = $_SESSION['username'];
if($userprofile)
{
}
else
{
header("location:login.php");
}
// for profile pic
$Query = "select * from users where user_name = '$userprofile'";
$runQuery = mysqli_query($con, $Query);
$data = mysqli_fetch_assoc($runQuery);
$profile_pic = $data['user_profile_picture'];
if(isset($_POST['insert_product']))
{
$product_name = $_POST['insert_product_name'];
$product_image = $_FILES['insert_product_image']['name'];
$img_temp_loc = $_FILES['insert_product_image']['tmp_name'];
$img_store = "product_images/".$product_image;
move_uploaded_file($img_temp_loc, $img_store);
$product_mode = $_POST['insert_product_mode'];
$confirm_pass = $_POST['confirm_password'];
$product_details = $_POST['insert_product_details'];
$time = date('d-m-y');
$owner_id = $data['user_id'];
if($confirm_pass == $data['user_password'])
{
$insert_query = "insert into products (product_name, product_mode, product_image, product_description, product_time, product_owner_id) values ('$product_name', '$product_mode', '$product_image', '$product_details', '$time', '$owner_id')";
$run_insert_query = mysqli_query($con, $insert_query);
if($run_insert_query)
{
echo "<script>alert('product uploaded successfully');</script>";
}
}
else{
echo "<script>alert('check your password again!');</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto ml-5">
<li class="nav-item active ml-5">
<a class="btn btn-danger" role="button" href="logout.php">Logout <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active ml-5">
<a class="nav-link" href="index.php">Home<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active ml-3">
<a class="nav-link" href="contact_session.php">Contact Us <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active ml-3">
<a class="nav-link" href="review.php">Rate Us/Blog<span class="sr-only">(current)</span></a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0 mr-5" action="" method="POST">
<input class="form-control mr-sm-2 " type="search" placeholder="Search" aria-label="Search" name="search_area">
<button class="btn btn-success my-2 my-sm-0 mr-5" type="submit" name="search_btn">Search</button>
</form>
<input id="mode" type="button" class="btn btn-light" value="Dark-Mode" onclick="change()">
</div>
</nav>
<?php
if(isset($_POST['search_btn']))
{
$search_result = $_POST['search_area'];
header("location:search.php?search_result=".$search_result);
}
?>
<br><br><br>
<div class="container-fluid">
<div class="row ">
<div class="col-sm-4 text-center" >
<?php echo"<img width='230' height='230' src='user_images/$profile_pic' alt='profile_pic' style='border-radius: 130px;'>" ?>
<h3 class="mt-5 mb-5" style="font-family:Stencil;"><?php echo $userprofile;?></h3>
<a href="view_account_details.php" class="nav-link"><h5>View Account Details</h5></a>
<a href="edit_Account_details.php" class="nav-link mt-1"><h5>Edit Account Details</h5></a>
<a href="review.php" class="nav-link mt-1"><H5>Write a Review</h5></a>
<a href="dashboard.php" class="nav-link mt-1"><h5>Back</h5></a>
</div>
<div class="col-sm-8">
<h3 class="alert alert-dark text-center">Insert a Product</h3>
<form class="ml-5 mr-5" action="" method="POST" enctype="multipart/form-data">
<div class="form-group mt-5 ml-5 mr-5">
<input type="text" name="insert_product_name" class="form-control" placeholder="enter product name" autocomplete="off" required>
</div>
<div class="form-group ml-5 mr-5">
<label for="product_image">Insert product image :</label>
<input id="product_image" type="file" name="insert_product_image" class="form-control" autocomplete="off" required>
</div>
<div class="form-group ml-5 mr-5">
<h4>Select The Mode : </h4>
<div class="form-check-inline">
<input type="radio" id="product_mode" name="insert_product_mode" class="form-check-input" value="Sale" required>
<label for="product_mode">Sale</label>
</div>
<div class="form-check-inline ml-5 mr-5">
<input type="radio" id="product_mode" name="insert_product_mode" class="form-check-input" value="Exchange" required>
<label for="product_mode">Exchange</label>
</div>
<div class="form-check-inline ml-5 mr-5">
<input type="radio" id="product_mode" name="insert_product_mode" class="form-check-input" value="Donate" required>
<label for="product_mode">Donate</label>
</div>
</div>
<div class="form-group ml-5 mr-5">
<input type="password" name="confirm_password" placeholder="confirm your password" required class="form-control">
</div>
<div class="form-group ml-5 mr-5">
<textarea type="text" class="form-control mt-4" placeholder="enter product details / description" name="insert_product_details" rows="6"></textarea>
</div>
<button class="btn btn-primary" name="insert_product" style="margin-left:45%;">SUBMIT</button>
</form>
</div>
</div>
<a href="chat_page.php"><img src="images/chat.png" class="fixed-bottom mb-3 ml-3" alt="chat-icon" width=100></a>
<script src="js/dark-mode.js"></script>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
$(document).ready(function()
{
$("body").animate({opacity:'1'}, 2000);
});
</script>
</body>
</html>