-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprojectUpdate.php
More file actions
174 lines (142 loc) · 7.55 KB
/
Copy pathprojectUpdate.php
File metadata and controls
174 lines (142 loc) · 7.55 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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
session_start();
include 'databaseConnection.php';
if ($error != null) {
echo '<p> cant connect to DB<br>';
}
else{
if (!isset($_SESSION['userID'])) {
echo "<script>alert('You are not logged in, please login or sign up first');</script>";
echo "<script>window.location = 'index.php';</script>";
exit();
}
if(!isset($_SESSION['userType']) || $_SESSION['userType']=="client") {
echo "<script> alert('You do not have access to this page');</script>";
echo "<script>window.location = 'clientHomepage.php';</script>";
}
}
// Get project ID
if (isset($_GET['projectId'])) {
$id = $_GET['projectId'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="projectAddition.css?v=<?php echo time(); ?>">
<link rel="stylesheet" href="basic.css?v=<?php echo time(); ?>">
<title>update page </title>
</head>
<body>
<header id="topBar">
<a href="designerHomePage.php"><img class="logo" alt="logo" src="images/lightBeigeLogo.png" ></a>
<a id="logout" href="logout.php">Log-out</a>
</header>
<main>
<div id="grid-home2">
<div id="textWrapper">
<p class="text">
<strong id="welcome"> Update project </strong>
</p>
</div>
</div>
<div class="info">
<h1>New Project</h1>
<!--<form action="projectUpdate.php" method="post" enctype="multipart/form-data">-->
<form action="projectUpdatePHP.php?projectId=<?php echo $id; ?>" method="post" enctype="multipart/form-data">
<?php
// retrieve project data
$sql = "SELECT * FROM designportoflioproject WHERE id=$id";
$result = mysqli_query($connection, $sql);
while ($row = mysqli_fetch_assoc($result)) {
$pName = $row['projectName'];
$pImg = $row["projectImgFileName"];
$description = $row['description'];
$designCategoryID = $row['designCategoryID'];
$sqlcat='SELECT * FROM designcategory WHERE id='.$designCategoryID;
$resulcat= mysqli_query($connection, $sqlcat);
while($rowcat= mysqli_fetch_assoc($resulcat)){
$designCategory = $rowcat['category'];
}
}
?>
<div class="item">
<label for="name">Project Name:</label> <br>
<?php echo '<input type="text" id="pName" name="pName" value="'.$pName.'" placeholder="Enter your project\'s name" required>'; ?>
</div> <br>
<label for="image">Upload file:</label><br>
<?php echo '<img src="images/'.$pImg.'" style="height: 90px; width: 150px;" ><br>'; ?>
<input type='file' id='image' name='image'> <br><br>
<div class="item">
<label for="name">Design Category:</label> <br>
<select name="category">
<?php
$sql='SELECT * FROM designcategory';
$result= mysqli_query($connection, $sql);
while($row= mysqli_fetch_assoc($result))
{
if ($row['category'] == $designCategory)
echo '<option selected name="'.$designCategory.'" value="'.$designCategory.'">'.$designCategory.'</option>';
if ($row['category'] != $designCategory)
echo '<option name="'.$row['category'].'" value="'.$row['category'].'">'.$row['category'].'</option>';
}
?>
</select>
</div> <br>
<div class="item">
<label for="description">Project Description:</label> <br>
<?php echo '<textarea id="description" name="description" placeholder="Enter your project\'s description" rows="8" cols="50">'.$description.'</textarea>'; ?>
</div> <br>
<input type='submit' value='Send' id="submitButten1" name="submitButten1">
</form>
</div>
</div>
</main>
<?php
// if(isset($_POST['submitButten1'])){
//
// $category = $_POST['category'];
// $categoryIDQuery = mysqli_query($connection, "SELECT id FROM designcategory WHERE category='$category'");
// $categoryIDAssoc = mysqli_fetch_assoc($categoryIDQuery);
// $categoryID = $categoryIDAssoc['id'];
//
// // Generate unique filename for the uploaded image
// $path_parts = pathinfo($_FILES["image"]["name"]);
// $extension = $path_parts['extension'];
// $filenewname = $pName . "_" . uniqid() . "." . $extension;
// $folder = "images/" . $filenewname;
//
//// echo '<script>alert("'.$_POST['pName'].'-'.$filenewname.' '.-$categoryID.' - '.$_POST['description'].' - '.$id.'");</script>';
//
// // Move uploaded file to the desired location
// if (move_uploaded_file($_FILES['image']['tmp_name'], $folder)) {
// echo '<script>alert("success to upload image.");</script>';
// $up = "UPDATE designportoflioproject SET projectName='" . $_POST['pName'] . "', projectImgFileName='" . $filenewname . "', "
// . "designCategoryID='" . $categoryID . "', description='" . $_POST['description'] . "' WHERE id =" . $id;
// $plsWork = mysqli_query($connection, $up);
// if($plsWork){
// echo '<script>alert("project was updated successfully.");</script>';
// echo '<script>window.location = "designerHomePage.php";</script>';
// }
// } else {
// echo '<script>alert("Failed to upload image.");</script>';
// }
// }//if
?>
<footer>
<p>Contact Us |Phone: 0116753695 |Email: <a id="email" href="mailto:LuminousDesign@LuminousDesign.com">LuminousDesign@LuminousDesign.com</a></p>
<p>Follow Us</p>
<div class="social-media-icons">
<a href=""><img src="images/x.png" alt="x icon" ></a>
<a href=""><img src="images/f.png" alt="facebook icon"></a>
<a href=""><img src="images/insta.png" alt="instagram icon"></a>
<a href=""><img src="images/in.png" alt="linkedIn icon"></a>
<a href=""><img src="images/p.PNG" alt="pintrest icon"></a>
<a href=""><img src="images/t.png" alt="tiktok icon"></a>
</div>
<p>© 2024 Luminous Design, All Rights Reserved.</p>
</footer>
</body>
</html>