-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproductNew.php
More file actions
64 lines (57 loc) · 2.11 KB
/
Copy pathproductNew.php
File metadata and controls
64 lines (57 loc) · 2.11 KB
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
<?php
session_start();
?>
<?php
include ('connect.php');
include('authenticationUser.php');
global $con;
global $user;
//is the user is a buyer, it should not be able to add new products
if ($user['isVendor']==0) {
header('location: landingPage.php');
}
//this query adds the new product
if (isset($_POST['sendForm'])) {
$name = $_POST['nameproduct'];
$price = $_POST['priceproduct'];
$link = $_POST['linkproduct'];
$result = $con->query("INSERT INTO product(`name`, `price`, `imgLink`, `creatorUserID`) VALUES ('$name',$price,'$link', $userid)");
if (!$result) {
echo "<script type='text/javascript'>alert('The product could not be inserted.');</script>";
} else {
echo "<script type='text/javascript'>alert('The product is inserted successully!');</script>";
}
}
$con->close();
?>
<!DOCTYPE html>
<html lang="en-us">
<?php include('head.php') ?>
<body>
<!-- TOP MENU -->
<?php include('menu.php') ?>
<div class="headerHello">
<div class="container">
<h1>Add a new Product</h1>
</div>
</div>
<!-- FORM -->
<div class="container">
<form class="formAddNewProduct" method='post'>
<div class="form-group">
<label for="inputEmail">Name product</label>
<input type="text" class="form-control" name="nameproduct" placeholder="Enter the name of the product">
</div>
<div class="form-group">
<label for="inputPrice">Price</label>
<input type="text" class="form-control" name="priceproduct" placeholder="Enter the name of the product">
</div>
<div class="form-group">
<label for="inputLink">Picture link</label>
<input type="text" class="form-control" name="linkproduct" placeholder="Enter the name of the product">
</div>
<input type="submit" name="sendForm" value="Add Product" class="button">
</form>
</div>
</body>
</html>