-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
120 lines (106 loc) · 4.12 KB
/
signup.html
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
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>RailMitra.com</title>
<link rel="stylesheet" href="css/lstyle.css">
</head>
<body>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>
<div class="container">
<div class="frame">
<div class="nav">
<ul class"links">
<li class="signup-active"><a class="btn">Sign up </a></li>
</ul>
</div>
<div>
<form class="form-signin" name="form">
<label for="fullname">Full name</label>
<input class="form-styling" type="text" name="fullname" id="name" placeholder="" pattern="[789]\d{9}"required />
<label for="email">Email</label>
<input class="form-styling" type="text" name="email" id="usersid" placeholder="" required />
<label for="fullname">Phone Number</label>
<input class="form-styling" type="text" name="phone" id="phone" placeholder="" required />
<label>Date of Birth </label>
<input type="text" class="form-styling" id="dateofbirth" name="dateofbirth" placeholder="DD-MM-YYYY" required>
<label for="gender">Gender</label>
<input type="radio" id="male" name="gender" >Male<br>
<input type="radio" id="female" name="gender">Female<br>
<label for="password">Password</label>
<input class="form-styling" type="password" name="password" id="passs" placeholder="" required />
<label for="confirmpassword">Confirm password</label>
<input class="form-styling" type="password" name="confirmpassword" placeholder="" required />
<button class="btn-signup" type="button" id="usersignup">Sign Up</button>
</form>
</div>
</div>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular.min.js'></script>
<script src="https://www.gstatic.com/firebasejs/4.13.0/firebase.js"></script>
<script>
var config = {
apiKey: "AIzaSyCYxMazGHf5ABlNvGXF7LVBia0mKsgX51c",
authDomain: "railmitra56.firebaseapp.com",
databaseURL: "https://railmitra56.firebaseio.com",
projectId: "railmitra56",
storageBucket: "railmitra56.appspot.com",
messagingSenderId: "1056408353044"
};
firebase.initializeApp(config);
</script>
<script>
function initApp() {
event.preventDefault();
document.getElementById('usersignup').addEventListener('click', usersignup);
}
function usersignup(){
var userid=document.getElementById("usersid").value;
var pass=document.getElementById("passs").value;
var name=document.getElementById("name").value;
var phone=document.getElementById("phone").value;
var dob=document.getElementById("dateofbirth").value;
var gender = document.querySelector('input[name = "gender"]:checked').value;
if(userid == 0|| pass == 0 || name==0 || phone==0||dob==0 ||gender==0)
{
alert("Please fill the input fields");
}
else{
firebase.auth().createUserWithEmailAndPassword(userid.trim(), pass).then(function(user){
var Ref=firebase.database().ref().child("users");
var newActivity={"name":name,"userid":userid,"phone":phone,"id":user.uid,"dateofbirth":dob,"password":pass,"gender":gender};
event.preventDefault();
console.log(newActivity);
Ref.child(user.uid).set(newActivity, function(err){
if(err){
alert("Data no go");
}
else
{
alert("User data has been submitted.")
window.open('dashboard.html',"_self");
}
});
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
var errorCode = error.code;
var errorMessage = error.message;
// [START_EXCLUDE]
if (errorCode == 'auth/weak-password') {
alert('The password is too weak.');
} else {
alert(errorMessage);
}
console.log(error);
});
}}
window.onload= function() {
initApp();
}
</script>
</body>
</html>