-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.php
153 lines (123 loc) · 5.18 KB
/
form.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
<?php
include ("connection.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Page</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="title">
<h1>Registration Page</h1>
</div>
<div class="container">
<form action="#"method="POST" enctype="multipart/form-data">
<div class="form">
<div class="input_field" style="width: 75%;">
<label for="IMG">Upload Image</label>
<input type="file" name="img_file" required>
</div>
<div class="input_field">
<label for="fname">First Name</label>
<input type="text" class="input" name="fname" required>
</div>
<div class="input_field">
<label for="lname">Last Name</label>
<input type="text" class="input" name="lname" required>
</div>
<div class="input_field">
<label for="password">Password</label>
<input type="password" class="input" name="password" required>
</div>
<div class="input_field">
<label for="confirm_password">Confirm Password</label>
<input type="password" class="input" name="con_password" required>
</div>
<div class="input_field">
<label for="gender">Gender</label>
<div class="custom_select">
<select name="gender" required>
<option value = "">Select</option>
<option vlaue = "male">Male</option>
<option value = "female">Female</option>
</select>
</div>
</div>
<div class="input_field">
<label for="email">Email Address</label>
<input type="text" class="input" name="email" required>
</div>
<div class="input_field">
<label for="phone">Phone Number</label>
<input type="text" class="input" name="phone" required>
</div>
<div class="input_field">
<label style="margin-right: 100px;" for="radio">Degree</label>
<input type="radio" name="deg" value="BSCS" required><label style="margin-left: 5px;">BSCS</label>
<input type="radio" name="deg" value="BSIT" required><label style="margin-left: 5px;">BSIT</label>
<input type="radio" name="deg" value="BSSE" required><label style="margin-left: 5px;">BSSE</label>
<input type="radio" name="deg" value="Other" required><label style="margin-left: 5px;">Other</label>
</div>
<div class="input_field">
<label for="checkbox" style="margin-right:75px;">Language</label>
<input type="checkbox" name="lang[]" value="English"><label style="margin-left: 5px;">English</label>
<input type="checkbox" name="lang[]" value="Urdu"><label style="margin-left: 5px;">Urdu</label>
<input type="checkbox" name="lang[]" value="Other"><label style="margin-left: 5px;">Other</label>
</div>
<div class="input_field">
<label for="address">Address</label>
<textarea class="textarea" name="address" required></textarea>
</div>
<div class="input_field terms">
<label class="check">
<input type="checkbox" required>
<span class="checkmark"></span>
</label>
<p>Agree to Terms and Conditions</p>
</div>
<div class="input_field">
<input type="submit" value="Register" class="btn" name="reg_btn">
</div>
<div class="login_here"> Already Have an Account ? <a href="login.php"> Login Here</a></div>
</div>
</form>
</div>
</body>
</html>
<!-- PHP Area -->
<?php
error_reporting(0);
if(isset($_POST['reg_btn'])) {
$filename = $_FILES["img_file"]["name"];
$tempname = $_FILES["img_file"]["tmp_name"];
$folder = "img/".$filename;
move_uploaded_file($tempname, $folder);
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$password = $_POST['password'];
$con_password = $_POST['con_password'];
$gender = $_POST['gender'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$degree = $_POST['deg'];
$language = $_POST['lang'];
$lang1 = implode(",", $language);
// echo $lang1;
$address = $_POST['address'];
// if($fname != "" && $lname != "" && $password != "" && $con_password != "" && $gender != "" && $email != "" && $phone != "" && $address != "") {
$query = "INSERT INTO form (img_file, fname, lname, password, con_password, gender, email, phone, degree, language, address) VALUES ('$folder','$fname', '$lname', '$password', '$con_password', '$gender', '$email', '$phone', '$degree', '$lang1', '$address')";
$data = mysqli_query($conn, $query);
if($data) {
echo "<script> alert('Data Inserted into db');</script>";
} else {
echo "<script> alert('Failed to insert data: ');</script>";
}
}
// else {
// echo "<script>alert('Fill the form to register!');</script>";
// }
// }
?>