-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
160 lines (128 loc) · 5.54 KB
/
signup.php
File metadata and controls
160 lines (128 loc) · 5.54 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
149
150
151
152
153
154
155
156
157
158
159
160
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="css/bootstrap.css">
<script src="javascript/signup.js"></script>
<title>Sign-Up</title>
</head>
<body class="bg-light">
<div class="Sign_in container-fluid text-center pt-3 ">
<h2>Sign-Up</h2>
</div>
<
<form name="signup" method="post" enctype="multipart/form-data" onsubmit="return validateForm()">
<div class="row mb-3 mx-5 pl-5">
<label for="" class="col-sm-2 col-form-label">Username</label>
<div class="col-sm-6">
<input type="text" id="username" class="form-control" placeholder="Must atleast be 6 character long" name="username">
</div>
</div>
<div class="row mb-3 mx-5 pl-5">
<label for="" class="col-sm-2 col-form-label">Name</label>
<div class="col-sm-3">
<input type="text" id="firstname" class="form-control" placeholder="First name" aria-label="First name" name="fname">
</div>
<div class="col-sm-3">
<input type="text" id="lastname" class="form-control" placeholder="Last name" aria-label="Last name" name="lname">
</div>
</div>
<div class="row mb-3 mx-5 pl-5">
<label for="" class="col-sm-2 col-form-label">Bio</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="bio" name="bio" placeholder="add a short bio">
</div>
</div>
<div class="row mb-3 mx-5 pl-5">
<label for="" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-6">
<input type="email" class="form-control" id="email" name="email">
</div>
</div>
<div class="row mb-3 mx-5 pl-5">
<label for="" class="col-sm-2 col-form-label">Password</label>
<div class="col-sm-6">
<input type="password" class="form-control" id="password" placeholder="8 to 20 characters" name="password">
</div>
</div>
<div class="row mb-3 mx-5 pl-5">
<label for="" class="col-sm-2 col-form-label">Confirm Password</label>
<div class="col-sm-6">
<input type="password" class="form-control" id="cpassword" name="cpassword">
</div>
</div>
<div class="row mb-3 mx-5 pl-5 img">
<label for="img" class="col-sm-2 col-form-label">Select image</label>
<div class="col-sm-6">
<input type="file" id="imagefile" name="imagefile">
</div>
</div>
<div class="text-center pt-2">
<button type="submit" class="btn btn-lg btn-success text-center " name="submit">Sign Up</button>
</div>
<div class="text-center pt-3">
<a href="http://localhost/NEW%20FOLDER/index.php">Already have an account?</a>
</div>
</form>
<?php
$dbServername = "localhost";
$dbUsername = "root";
$dbPassword ="";
$dbName="webproject";
$conn= mysqli_connect($dbServername,$dbUsername,$dbPassword,$dbName);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// echo 'Connected successfully'.'<br>';
// echo $pass;
// echo $cpass;
//echo $img;
//$sql="INSERT INTO user (username, firstname, lastname, email, pass, joining_date) VALUES ('$username','$firstname','$lastname','$email', '$pass','$date')";
if (isset($_POST["submit"])) {
$username=$_POST['username'];
$firstname=$_POST['fname'];
$lastname=$_POST['lname'];
$bio=$_POST['bio'];
$email=$_POST['email'];
$pass=$_POST['password'];
$cpass=$_POST['cpassword'];
if (getimagesize($_FILES['imagefile']['tmp_name']) == false) {
echo "<br />Please Select An Image.";
}
else {
// echo "failed<br>";
$name = $_FILES['imagefile']['tmp_name'];
$image = $_FILES['imagefile']['name'];
$image_folder='uploaded/'.$image;
$sql="INSERT INTO user (username, firstname, lastname, email, pass, bio, photo) VALUES ('$username','$firstname','$lastname','$email', '$pass','$bio','$image')";
if (mysqli_query($conn, $sql))
{
move_uploaded_file($name,$image_folder);
session_start();
$_SESSION['signup']='successfull';
header('location:http://localhost/NEW%20FOLDER/index.php');
}
else {
header('location:http://localhost/NEW%20FOLDER/signup.php');
}
}
}
?>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
</body>
</html>