This repository was archived by the owner on Mar 15, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathinsert_record.php
More file actions
executable file
·149 lines (112 loc) · 4.01 KB
/
Copy pathinsert_record.php
File metadata and controls
executable file
·149 lines (112 loc) · 4.01 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
<?php
include 'header.php';
include 'connect.php';
include 'safein.php';
///////////////////////////////////////////////////////////////////////////////////////////// Upload
$First_Name = $_POST['First_Name'];
$Father_Name = $_POST['Father_Name'];
$Sure_Name = $_POST['Sure_Name'];
$Saudi_ID = $_POST['Saudi_ID'];
$Cnum = $_POST['Cnum'];
$Gender = $_POST['Gender'];
$DOB_Day = $_POST['DOB_Day'];
$DOB_Month = $_POST['DOB_Month'];
$DOB_Year = $_POST['DOB_Year'];
$Mobile = $_POST['Mobile'];
$EPT_Date_Day = $_POST['EPT_Date_Day'];
$EPT_Date_Month = $_POST['EPT_Date_Month'];
$EPT_Date_Year = $_POST['EPT_Date_Year'];
$EPT = $_POST['EPT'];
$Specialty = $_POST['Specialty'];
$Experience = $_POST['Experience'];
$Qualifications = $_POST['Qualifications'];
$Category = $_POST['Category'];
$GPA = $_POST['GPA'];
$Status = $_POST['Status'];
$Comments = $_POST['Comments'];
$Creator = $_POST['Creator'];
$Lastupdate = $_POST['Lastupdate'];
//allowedExts variable is an array consisting of file types that can be supported.we are uploading image so image file extensions are used.
$allowedExts = array("gif", "jpeg", "jpg", "png", "zip","x-zip","x-zip-compressed","pdf","x-pdf");
//explode function breaks the string, here used to get the file extension, whenever
//a dot(.) would be found in the filename,say abc.jpg, the extension jpg would be
//retrived.
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if (empty($_FILES['file']['name']))
{
header('Refresh: 3; url=new_record.php');
?>
<div class="clear">
</div>
<div class="msg-col">
<div class="msg-logo"><img src="./images/error.png"></div>
<div class="box-sec" style="text-align:center;">
<b><? echo "empty file";?>
</b>
</div>
</div>
<?
}
else {
//if any error in file, display it
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
//else upload the file
else
{
$newname = date('dmYhms');
$imagedbtype = $_FILES["file"]["type"];
$imagedbsize = ($_FILES["file"]["size"] / 1024);
//file will be uploaded in the upload directory..but also need to check whether
//the directory consists a same filename already or not..if it does contains
// a file say abc.jpg already..it would display the msg file already exist
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
//else it will upload it in upload directory, you can name the directory acc to you..
//but conventionally upload is used as the directory name
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $newname . "." . $extension);
$imagepath = "upload/" . $newname . "." . $extension ;
// Data insert lines
$sql_1="INSERT INTO files (upload_name, url, type, size)
VALUES
('$newname','$imagepath','$imagedbtype','$imagedbsize')";
// Data insert lines
$sql_2="INSERT INTO entry (First_Name, Father_Name, Sure_Name, Saudi_ID, Cnum, Gender, DOB_Day, DOB_Month ,DOB_Year, Mobile, EPT_Date_Day, EPT_Date_Month, EPT_Date_Year, EPT, Specialty ,Experience, Category, GPA, Qualifications, Status, Comments, upload_name, Creator, Lastupdate)
VALUES
('$First_Name','$Father_Name','$Sure_Name','$Saudi_ID','$Cnum','$Gender','$DOB_Day','$DOB_Month','$DOB_Year','$Mobile','$EPT_Date_Day','$EPT_Date_Month','$EPT_Date_Year','$EPT','$Specialty','$Experience','$Category','$GPA','$Qualifications','$Status','$Comments','$newname','$Creator','$Lastupdate')";
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8');
if (!mysql_query($sql_1))
{
die('Error: ' . mysql_error());
}
if (!mysql_query($sql_2))
{
die('Error: ' . mysql_error());
}
?>
<div class="clear">
</div>
<div class="msg-col">
<div class="msg-logo"><img src="./images/success.png"></div>
<div class="box-sec" style="text-align:center;">
<b>Successed!</b>
</div>
</div>
<?
header('Refresh: 3; url=new_record.php');
}
}
?>
<?
}
//////////////////////////////////////////////////////////////////////////////////////// Upload
?>