-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy paths_f_add.php
executable file
·193 lines (174 loc) · 5.17 KB
/
s_f_add.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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="includes/main.css" type="text/css" />
<title>E-Learning: Add Student</title>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
<body>
<?php include ("includes/top_line.php"); ?>
<?php include ("includes/faculty_main_menu.php"); ?>
<div id="mid">
<img src="images/Ichalkarnji.jpg"/>
</div>
<div id="text">
<b>Add Student</b>
<?php session_start();
?>
<form action="s_f_add.php" method="post">
<table>
<tr>
<td>Student Name: </td>
<td><input type="text" name="name" size="50" /></td>
</tr>
<tr>
<td>Gender: </td>
<td>
<input type="radio" name="gender" value="male" checked="checked" /> Male
<input type="radio" name="gender" value="female" /> Female
</td>
</tr>
<tr>
<td>Address: </td>
<td><input type="text" name="address" size="50" /></td>
</tr>
<tr>
<td>Contact No.: </td>
<td><input type="text" name="contact_no" /></td>
</tr>
<tr>
<td>Email ID: </td>
<td><input type="text" name="email_id" size="40"/></td>
</tr>
<tr>
<td>Parents Name: </td>
<td><input type="text" name="parents_name" size="50"/></td>
</tr>
<tr>
<td>Parents Contact No.: </td>
<td><input type="text" name="parents_contact_no" /></td>
</tr>
<tr>
<td>Branch: </td>
<td>
<select name="branch">
<?php
include "dbconnection.php";
$query = "SELECT * FROM department";
$result = mysql_query($query,$con) or die();
while($row = mysql_fetch_array($result))
{
echo '<option>'.$row['branch'] .'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>Class: </td>
<td>
<select name="class">
<option>
FE
</option>
<option>
SE
</option>
<option>
TE
</option>
<option>
BE
</option>
</select>
</td>
</tr>
<tr>
<td>Roll No: </td>
<td><input type="text" name="roll_no" size="20" /></td>
</tr>
<tr>
<td>User Name: </td>
<td><input type='text' name='user_name' id='username' maxlength="50" /></td>
</tr>
<tr>
<td>Password: </td>
<td><input type='password' name='password' id='password' maxlength="50" /></td>
</tr>
<tr>
<td>Confirm Password: </td>
<td><input type='password' name='confirm_password' id='password' maxlength="50" /></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="submit" value="Add">
</td>
</tr>
</table>
</form>
</div>
<?php
include "dbconnection.php";
$query = "SELECT * FROM student";
$result = mysql_query($query,$con) or die();
$f = 0;
if($_POST)
{
if(!empty($_POST['branch']) && !empty($_POST['class']) && !empty($_POST['name']) && !empty($_POST['gender']) && !empty($_POST['address']) && !empty($_POST['contact_no']) && !empty($_POST['email_id']) && !empty($_POST['parents_name']) && !empty($_POST['parents_contact_no']) && !empty($_POST['roll_no']) && !empty($_POST['user_name']) && !empty($_POST['password']) && !empty($_POST['confirm_password']))
{
while($row = mysql_fetch_array($result))
{
if(($row['name'] == $_POST['name']) && ($row['branch'] == $_POST['branch']) && ($row['class'] == $_POST['class']) && ($row['roll_no'] == $_POST['roll_no']))
{
echo '<html><head><script type="text/javascript">alert("You are already registered!!!");</script></head></html>';
$f = 1;
break;
}
}
if($f == 0)
{
if(!empty($_POST['user_name']))
{
$query = "SELECT * FROM login";
$result = mysql_query($query,$con) or die();
$f1 = 0;
while($row = mysql_fetch_array($result))
{
if($row['user_name'] == $_POST['user_name'])
{
echo '<html><head><script type="text/javascript">alert("User Name already esist!!!");</script></head></html>';
$f1 = 1;
}
}
if($f1 == 0)
{
$fp = 0;
if($_POST['password'] != $_POST['confirm_password'])
{
echo '<html><head><script type="text/javascript">alert("Password incorrect!!!");</script></head></html>';
$fp = 1;
}
if($fp == 0)
{
$queryl = "INSERT INTO login VALUES ('$_POST[user_name]', '$_POST[password]', 'student')";
mysql_query($queryl,$con) or die();
$query = "INSERT INTO student VALUES ('$_POST[name]' , '$_POST[gender]', '$_POST[address]', '$_POST[contact_no]', '$_POST[email_id]', '$_POST[parents_name]', '$_POST[parents_contact_no]', '$_POST[branch]', '$_POST[class]', '$_POST[roll_no]', '$_POST[user_name]', '$_POST[password]', '".date('d-m-Y')."')";
mysql_query($query,$con) or die();
echo '<html><head><script type="text/javascript">alert("Record saved successfully.");</script></head></html>';
}
}
}
}
}
}
mysql_close($con);
?>
<div id="line">
</div>
<?php include ("includes/bottom_line.php"); ?>
</body>
</html>