-
Notifications
You must be signed in to change notification settings - Fork 0
/
n.php
121 lines (65 loc) · 2.67 KB
/
n.php
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
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="student.css">
</head>
<body>
<?php
session_start();
include("config.php");
if(isset($_POST['but_upload'])){
$name = $_FILES['file']['name'];
$Email=$_POST["email"];
$rollno=$_POST["rollno"];
$year=$_POST["year"];
$address=$_POST["address"];
$username=$_POST["username"];
/*--- we created a variables to display the error message on design page ------*/
$error = "";
if (isset($_POST["but_upload"]) == "Upload")
{
$file_tmp = $_FILES["file"]["tmp_name"];
$file_name = $_FILES["fileImg"]["name"];
/*image name variable that you will insert in database ---*/
//image directory where actual image will be store
$file_path = "student/".$file_name;
/*---------------- php textbox validation checking ------------------*/
if($name == "")
{
$error = "Please enter Image name.";
}
/*-------- now insertion of image section has start -------------*/
else
{
if(file_exists($file_path))
{
$error = "Sorry,The <b>".$file_name."</b> image already exist.";
}
else
{
$query = "insert into student(name,image,email,year,rollno,address,username) values('".$name."','".$image."','".$Email."','".$year."','".$rollno."','".$address."','".$username."')";
$error = "<p align=center>File ".$_FILES["fileImg"]["name"].""."<br />Image saved into Table.";
}
}
}
?>
<?php include 'header.php'; ?>
<center>
<div style="width: 400px;height: 340px;box-shadow: 3px 3px 3px 3px grey; margin-top: 50px;"> <a href="afterlogin.php"><div style="float: left;"><button>Back</button></div></a>
<a href="logout.php"><div style="float: right;"><button>Logout</button></div></a>
<form method="post" action="" enctype='multipart/form-data' id="myform">
<h1>!Add Student!</h1>
<input type='text' name='username'placeholder='Name'required><br><br>
<input type='text' name='rollno'placeholder='Rollno'required><br><br>
<input type='email' name='email'placeholder='Email'required><br><br>
<input type='text' name='year'placeholder='Year'required><br><br>
<textarea name='address'placeholder='address'required></textarea><br><br>
<input type='file' name='file' ><br><br>
<input type='submit' name='but_upload'>
</form>
</div>
</center>
</body>
</html>
<?php include 'footer.php'; ?>