-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser.php
208 lines (190 loc) · 5.91 KB
/
user.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
include("header.php");
include("connection.php");
$dt = date("Y-m-d");
if(isset($_POST[Update]))
{
$sql="INSERT INTO user (inst_id,emp_fname, emp_lname, gender,s_emailid,password,created_at)
VALUES ('$_POST[institutionname]','$_POST[firstname]','$_POST[lastname]','$_POST[gender]','$_POST[emailid]','$_POST[password2]','$dt')";
if (!mysqli_query($con,$sql,$con))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
}
$result = mysqli_query($con,"SELECT * FROM institute");
?>
<script language="javascript">
function validate()
{
var x=document.form1.emailid.value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if(document.form1.firstname.value=="")
{
alert("Please enter Firstname");
document.form1.firstname.focus();
return false;
}
else if(document.form1.firstname.value.length<4 || document.form1.firstname.value.length>10 )
{
alert("first name must be greater than 4 letters and less than 10 letters");
document.form1.firstname.focus();
return false;
}
else if(document.form1.lastname.value=="")
{
alert("Please enter Lastname");
document.form1.lastname.focus();
return false;
}
else if(document.form1.lastname.value.length<4 || document.form1.lastname.value.length>10 )
{
alert("last name must be greater than 4 letters and less than 10 letters");
document.form1.lastname.focus();
return false;
}
else if(document.form1.emailid.value=="")
{
alert("Please enter the email id");
document.form1.emailid.focus();
return false;
}
else if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
else if(document.form1.password2.value=="")
{
alert("Please enter the Password");
document.form1.password2.focus();
return false;
}
else if(document.form1.password2.value.length<8 || document.form1.password2.value.length>15 )
{
alert("minimum charaters for password is 8 and maximum character is 15");
document.form1.password2.focus();
return false;
}
else if(document.form1.confirmpassword.value=="")
{
alert("Please enter confirm password");
document.form1.confirmpassword.focus();
return false;
}
else if(document.form1.password2.value != document.form1.confirmpassword.value)
{
alert("password and confirm password is not matching");
document.form1.confirmpassword.value="";
document.form1.password2.focus();
return false;
}
else if(document.form1.institutionname.value=="")
{
alert("Please enter Institution name");
document.form1.institutionname.focus();
return false;
}
}
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
//alert(charCode);
if (charCode > 65 && charCode < 91 )
{
return true;
}
else if (charCode > 95 && charCode < 122 )
{
return true;
}
else
{
alert("should be alphabet");
return false;
}
}
</script>
<div id="main">
<div id="content" class="left">
<div class="highlight">
<h3><a href="viewusers.php"></a>Add Users</h3>
<form id="form1" name="form1" method="post" action="" onsubmit="return validate()" >
<p><a href="viewusers.php"><strong>View Users</strong></a></p>
<table width="530" border="0">
<tr>
<td width="152">First name</td>
<td width="368"><input name="firstname" type="text" id="firstname" size="50" onKeyPress="return isNumberKey(event)" /></td>
</tr>
<tr>
<td>Last name</td>
<td><input name="lastname" type="text" id="lastname" size="50" onKeyPress="return isNumberKey(event)"/></td>
</tr>
<tr>
<td><label for="Gender" >Gender</label></td>
<td><input type="radio" name="gender" id="gender2" value="male" checked="checked" />
<label for="gender3">Male
<input type="radio" name="gender" id="gender" value="female" />
</label>
<label for="gender4">Female</label></td>
</tr>
<tr>
<td>Email id</td>
<td><input name="emailid" type="text" size="50" /></td>
</tr>
<tr>
<td><label for="password3">Password</label></td>
<td><input name="password2" type="password" id="password2" size="50" /></td>
</tr>
<tr>
<td><label for="confirmpassword2">Confirm password</label></td>
<td><input name="confirmpassword" type="password" id="confirmpassword" size="50" /></td>
</tr>
<tr>
<td>Institution name</td>
<td><select name="institutionname" id="institutionname"><option value="">select</option>
<?php
while($row = mysqli_fetch_array($result))
{
echo "<option value='$row[inst_id]'> $row[inst_id] $row[inst_name]</option>";
}
?>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Update" id="Update" value="Add user" /></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</form>
<p> </p>
</div>
<div class="projects">
<div class="item"></div>
<div class="item">
<div class="cl"> </div>
</div>
</div>
</div>
<?php
include("sidebar.php");
?>
<div class="cl"> </div>
</div>
<div class="shadow-l"></div>
<div class="shadow-r"></div>
<div class="shadow-b"></div>
</div>
<?php
include("footer.php");
?>