0% found this document useful (0 votes)
4 views8 pages

Student Profile Photo Upload Form

Uploaded by

22x51a05d6
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

Student Profile Photo Upload Form

Uploaded by

22x51a05d6
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

index.

php

1 <!-- ****************** Code For Uploading Photo************** -->


2 <?php
3 if (isset($_POST["submit"])) {
4
5 if (isset($_FILES["image"]))
6 {
7 $targetDir = "uploads/";
8 $targetFile = $targetDir . basename($_FILES["image"]["name"]);
9 $uploadOk = 1;
10 $imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));
11
12 $check = getimagesize($_FILES["image"]["tmp_name"]);
13 if ($check !== false) {
14 #echo "File is an image - " . $check["mime"] . ".";
15 $uploadOk = 1;
16 } else {
17 echo "File is not an image.";
18 $uploadOk = 0;
19 }
20 }
21 // Check if the file already exists in the same path
22 if (file_exists($targetFile))
23 {
24 echo "Sorry, file already exists.";
25 $uploadOk = 0;
26 }
27 // Check file size and throw error if it is greater than
28 // the predefined value, here it is 500000
29 if ($_FILES["image"]["size"] > 500000) {
30 echo "Sorry, your file is too large.";
31 $uploadOk = 0;
32 }
33 // Check for uploaded file formats and allow only
34 // jpg, png, jpeg and gif
35 // If you want to allow more formats, declare it here
36 if (
37 $imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
38 && $imageFileType != "gif"
39 ) {
40 echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
41 $uploadOk = 0;
42 }
43
44 // Check if $uploadOk is set to 0 by an error
45 if ($uploadOk == 0) {
46 echo "Sorry, your file was not uploaded.";
47 } else {
48 if (move_uploaded_file($_FILES["image"]["tmp_name"], $targetFile)) {
49 # echo "The file " . htmlspecialchars(basename($_FILES["image"]["name"])) . " has
been uploaded.";
50 } else {
51 echo "Sorry, there was an error uploading your file.";
52 }
53 }
54 }
55 ?>
56
57 <!DOCTYPE html>
58 <html>
59 <head>
60 <title>Student Profile</title>
61 <link rel='stylesheet'
href='[Link]
'>
62 </head>
63
64 <body>
65 <div class="phppot-container">
66 <h1 align="center" >Enter Student Data</h1>
67 <hr color="blue"/>
68 <form action="" method="post" enctype="multipart/form-data">
[Link]

69 <section>
70 <div class="rt-container">
71 <div class="col-rt-12">
72 <div class="Scriptcontent">
73
74 <!-- ************************Student Profile Read Code From Here******************** -->
75 <div class="student-profile py-4">
76 <div class="container">
77 <div class="row">
78 <div class="col-lg-8">
79 <div class="card shadow-sm">
80 <div class="card-body pt-0">
81
82 <table class="table table-bordered" align="center">
83 <tr>
84 <th width="30%">Student Name:</th>
85 <td width="2%">:</td>
86 <td><input type="text" name="sname"/></td>
87 </tr>
88 <tr>
89 <th width="30%">Student ID:</th>
90 <td width="2%">:</td>
91 <td><input type="text" name="sid"/></td>
92 </tr>
93
94 <tr>
95 <th width="30%">Class:</th>
96 <td width="2%">:</td>
97 <td><input type="text" name="sclass" id="sclass"/></td>
98 </tr>
99 <tr>
100 <th width="30%">Section:</th>
101 <td width="2%">:</td>
102 <td><input type="text" name="ssection" id="ssection"/></td>
103 </tr>
104
105 <tr>
106 <th width="30%">Roll</th>
107 <td width="2%">:</td>
108 <td><input type="text" name="sroll" id="sroll"/></td>
109 </tr>
110 <tr>
111 <th width="30%">Academic Year </th>
112 <td width="2%">:</td>
113 <td><input type="text" name="syear" id="syear"/></td>
114 </tr>
115 <tr>
116 <th width="30%">Gender</th>
117 <td width="2%">:</td>
118 <td>Male:<input type="radio" name="sg" id="sg"/>Female<input type="radio"
name="sg" id="sg"/></td>
119 </tr>
120 <tr>
121 <th width="30%">Religion</th>
122 <td width="2%">:</td>
123 <td><input type="text" name="sr" id="sr"/></td>
124 </tr>
125 <tr>
126 <th width="30%">blood</th>
127 <td width="2%">:</td>
128 <td><input type="text" name="sb" id="sb"/></td>
129 </tr>
130 <tr>
131 <th width="30%">Photo</th>
132 <td width="2%">:</td>
133 <td><input type="file" name="image" required></td>
134 </tr>
135 <tr>
136 <td colspan="3" align="center"><input type="submit" name="submit"
value="Submit"></td>
137 </tr>
[Link]

138
139 </table>
140 <div class="row">
141 </div>
142 </form>
143 <hr color="red" />
144 <!-- *******************Student Display Starts From Here******************************-->
145 <?php if (isset($_FILES["image"]) && $uploadOk == 1) : ?>
146 <h1>Student Profile</h1>
147
148 <table class="table table-bordered">
149 <tr>
150 <th width="30%">Student Name:</th>
151 <td width="2%">:</td>
152 <td>
153 <?php
154 $name=$_POST["sname"];
155 echo $name;
156 ?>
157 </td>
158 <td><img src="<?php echo $targetFile; ?>" alt="Uploaded Image"></td>
159 </tr>
160
161 <tr>
162 <th width="30%">Student ID:</th>
163 <td width="2%">:</td>
164 <td>
165 <?php
166 $name=$_POST["sid"];
167 echo $name;
168 ?>
169 </td>
170 </tr>
171
172 <tr>
173 <th width="30%">Class:</th>
174 <td width="2%">:</td>
175 <td>
176 <?php
177 $name=$_POST["sclass"];
178 echo $name;
179 ?>
180 </tr>
181 <tr>
182 <th width="30%">Section:</th>
183 <td width="2%">:</td>
184 <td>
185 <?php
186 $name=$_POST["ssection"];
187 echo $name;
188 ?>
189 </tr>
190
191 <tr>
192 <th width="30%">Roll</th>
193 <td width="2%">:</td>
194 <td>
195 <?php
196 $name=$_POST["sroll"];
197 echo $name;
198 ?>
199 </tr>
200 <tr>
201 <th width="30%">Academic Year </th>
202 <td width="2%">:</td>
203 <td>
204 <?php
205 $name=$_POST["syear"];
206 echo $name;
207 ?>
208 </tr>
[Link]

209
210 <tr>
211 <th width="30%">Gender</th>
212 <td width="2%">:</td>
213 <td>
214 <?php
215 $name=$_POST["sg"];
216 echo $name;
217 ?>
218 </tr>
219
220 <tr>
221 <th width="30%">Religion</th>
222 <td width="2%">:</td>
223 <td>
224 <?php
225 $name=$_POST["sr"];
226 echo $name;
227 ?>
228 </tr>
229
230 <tr>
231 <th width="30%">blood</th>
232 <td width="2%">:</td>
233 <td>
234 <?php
235 $name=$_POST["sb"];
236 echo $name;
237 ?>
238 </tr>
239 </table>
240
241 </div>
242 </div>
243 <div style="height: 26px"></div>
244 </div>
245 </div>
246 </div>
247 </div>
248 </div>
249 </div>
250 </div>
251 </section>
252 <?php endif; ?>
253 </div>
254 </body>
255 </html>
Module-4: Input
Output :-

You might also like