-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCompanyDetails.php
151 lines (135 loc) · 5.71 KB
/
CompanyDetails.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
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Company Details - JobAssembler</title>
<!-- Bootstrap CSS 5.1.3-->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<style type="text/css">
body {
display: flex;
justify-content: center;
background-image: linear-gradient(to left, #e1eec3, #f05053);
}
.container-fluid{
background-color: #fff;
width: 80%;
height: 110%;
position: relative;
display: flex;
border-radius: 80px;
justify-content: center;
align-items: center;
top: 50px;
font-size:40px;
margin-bottom: 10%;
}
.b{
width: 77%;
height: 90%;
overflow: hidden;
font-family:"Helvetica";
padding: 5%;
}
.display-1{
font: 900 15px '';
font-size:1.3em;
font-family:"Helvetica";
margin: 5px 0;
text-align: center;
letter-spacing: 1px;
}
.inputBox{
width: 100%;
margin-bottom: 20px;
outline: none;
border: 0;
padding: 5px;
border-bottom: 2px solid rgb(60,60,70);
font: 900 16px '';
font-size:30px;
}
label{
float:left;
}
#validationMsg{
text-align:center;
color:red;
font-size:30px;
}
</style>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
function ValidateForm(name, description, warning){
warning.innerHTML = ""; //Set it to blank first in case the user got the validation wrong first time round.
if(/^[0-9a-z\s]+$/i.test(name.value) == false || name.value.length > 64 || name.value.length < 3){
warning.innerHTML = "Company name must be between 3 and 64 alphanumeric characters.";
}else if(description.value.length < 20){
warning.innerHTML = "Please ensure you've added an appropriate description (over 20 characters long).";
}
if(warning.innerHTML != ""){
return false;
}else{
return true;
}
}
$(document).ready(function(){
$("#companyForm").submit(function (e){
let warning = document.getElementById("validationMsg");
e.preventDefault(); //Stops the normal HTML form behaviour of changing files
let form = document.getElementById('companyForm');
var validForm = ValidateForm(form.elements[0], form.elements[1], warning);
form.elements[2].value = localStorage.getItem("userID");
if(validForm){
$.ajax({
type:"POST",
url:"api/companyRegister.php",
data: $(this).serialize(),
success: function(data){
localStorage.removeItem("userID");
window.location = "login.php"; //Where to go if successful (Needs changing to the main screen)
},
error: function(xhr){
//alert($(this).serialize);
var obj = xhr.responseJSON;
//alert("An error occured: " + xhr.status + " " + xhr.statusText);
if(Object.keys(obj).includes("message")){
warning.innerHTML = obj["message"];
}else{
warning.innerHTML = "An unknown error has occurred. Please try again later.";
}
}
})
}
})
})
</script>
</head>
<body>
<div class="container-fluid">
<div class="b">
<h1 class="display-1" align="center">Company Details</h1>
<form id="companyForm" name="companyForm">
<br>
<label for="name">Company Name:</label>
<br>
<input type="text" name="name" id="name" class="inputBox">
<br>
<br>
<label for="description">Description:</label>
<br>
<textarea id="description" rows="3" cols="50" name="description" class="inputBox"></textarea>
<br>
<br>
<input type="hidden" name="userID" id="userID">
<input type="submit" class="btn btn-primary btn-lg" style="margin-left:40%;" value="Submit">
<br>
<a href="login.php">Or login to join a pre-existing company</a>
<p id="validationMsg"></p>
</form>
</div>
</div>
</body>
</html>