-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit.php
More file actions
105 lines (85 loc) · 3.25 KB
/
Copy pathsubmit.php
File metadata and controls
105 lines (85 loc) · 3.25 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
<?php
session_start();
require('config/db.php');
if(isset($_POST['login'])) {
$name=$_POST["name"];
$rollno=$_POST["rollno"];
$specialization=$_POST["specialization"];
$research=$_POST["research"];
$abstract=$_POST["abstract"];
$publications=$_POST["publications"];
$awards=$_POST["awards"];
$subtext1=$_POST["subtext1"];
$subtext2=$_POST["subtext2"];
$subtext3=$_POST["subtext3"];
$errors= array();
$file_name = $_FILES["image1"]['name'];
$file_size = $_FILES["image1"]['size'];
$file_tmp = $_FILES["image1"]['tmp_name'];
$file_type = $_FILES["image1"]['type'];
$rollno = strtoupper($rollno);
(file_exists("images/".$rollno."_1.jpg")?unlink("images/".$rollno."_1.jpg"):1);
(file_exists("images/".$rollno."_2.jpg")?unlink("images/".$rollno."_2.jpg"):1);
(file_exists("images/".$rollno."_3.jpg")?unlink("images/".$rollno."_3.jpg"):1);
$_SESSION["file_ext1"]=strtolower(end(explode('.',$_FILES['image1']['name'])));
// echo "Image Variavles alloted";
// $expensions= array("jpg","jpeg","png");
// if(in_array($file_ext,$expensions)=== false)
// {
// $errors[]="Given extension not allowed, please choose a JPG only";
// }
// if(empty($errors)==true)
// {
// echo "Hello world";
move_uploaded_file($file_tmp,"images/".$rollno."_1.jpg");
echo "image1 success!";
// }else{
// print_r($errors);
// }
$errors= array();
$file_name = $_FILES['image2']['name'];
$file_size = $_FILES['image2']['size'];
$file_tmp = $_FILES['image2']['tmp_name'];
$file_type = $_FILES['image2']['type'];
$_SESSION["file_ext2"]=strtolower(end(explode('.',$_FILES['image2']['name'])));
// $expensions= array("jpg","jpeg","png");
// if(in_array($file_ext,$expensions)=== false)
// {
// $errors[]="Given extension not allowed, please choose a JPG only";
// }
// if(empty($errors)==true)
// {
move_uploaded_file($file_tmp,"images/".$rollno."_2.jpg");
echo "image2 success!";
// }else{
// print_r($errors);
// }
$errors= array();
$file_name = $_FILES['image3']['name'];
$file_size = $_FILES['image3']['size'];
$file_tmp = $_FILES['image3']['tmp_name'];
$file_type = $_FILES['image3']['type'];
$_SESSION["file_ext3"]=strtolower(end(explode('.',$_FILES['image3']['name'])));
// $expensions= array("jpg","jpeg","png");
// if(in_array($file_ext,$expensions)=== false)
// {
// $errors[]="Given extension not allowed, please choose a JPG only";
// }
// if(empty($errors)==true)
// {
move_uploaded_file($file_tmp,"images/".$rollno."_3.jpg");
echo "image3 success!";
// }else{
// print_r($errors);
// }
$sql = "DELETE FROM collection WHERE rollno='".$rollno."';";
// use exec() because no results are returned
$conn->exec($sql);
$sql = "INSERT INTO collection (name, rollno, specialization, research, abstract, publications, awards, subtext1, subtext2, subtext3)
VALUES ('$name', '$rollno', '$specialization', '$research', '$abstract', '$publications', '$awards', '$subtext1', '$subtext2', '$subtext3')";
// use exec() because no results are returned
$conn->exec($sql);
header("Location: page.php?rollno=".$rollno);
$conn = null;
}
?>