forked from RittickSR/EIN_Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign2.php
173 lines (155 loc) · 7.01 KB
/
sign2.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
<?php
require 'dbconfig/cofig.php';
include "pass.php";
session_start();
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Employer Signup Form </title>
<link rel="stylesheet" type="text/css" href="style/newsign.css">
</head>
<body>
<div id="login-box">
<div class="left-box">
<h1> Sign Up</h1>
<form id="sign-form" method="post" action="sign2.php">
<input type="text" name="name" placeholder="Company name" maxlength=30 required/>
<input type="text" value="" name="username" placeholder="Username" method="post" required/>
<input type="text" name="address" placeholder="Company address" maxlength=30 required/>
<input type="text" name="rnumber" placeholder="Company registration number"maxlength=30 required/>
<input type="text" name="mnumber" placeholder="Mobile number"maxlength=10 required/>
<input type="text" name="email" placeholder="Email"maxlength=30 required/>
<input type="password" name="pass" placeholder="Password"maxlength=30 id="pass" required/>
<input type="password" name="cpass" placeholder="Confirm password" maxlength=30 id="cpass" required/>
<input type="checkbox" onclick="validatePassword();">Show Password<br><br>
<script>
function validatePassword()
{
var x = document.getElementById("pass");
var y = document.getElementById("cpass");
if ((x.type === "password")||(y.type==="password"))
{
x.type = "text";
y.type = "text";
}
else
{
x.type = "password";
y.type = "password";
}
}
</script>
<input type="submit" name="submit" value="submit"/>
</form>
</div>
<?php
if(isset($_POST['submit']))
{ $_SESSION['username']=$_POST['username'];
$_SESSION['name']=$_POST['name'];
$_SESSION['username']=$_POST['username'];
$_SESSION['address']=$_POST['address'];
$_SESSION['rnumber']=$_POST['rnumber'];
$_SESSION['mnumber']=$_POST['mnumber'];
$_SESSION['email']=$_POST['email'];
$_SESSION['pass']=$_POST['pass'];
$_SESSION['cpass']=$_POST['cpass'];
$name=$_SESSION['name'];
$username=$_SESSION['username'];
$address=$_SESSION['address'];
$rnumber=$_SESSION['rnumber'];
$mnumber=$_SESSION['mnumber'];
$email=$_SESSION['email'];
$password=$_SESSION['pass'];
$cpassword=$_SESSION['cpass'];
$hpass=passhash($password);
$query="select * from employer1 WHERE email='$email'";
$query_run= mysqli_query($con,$query);
if(mysqli_num_rows($query_run)>0)
{
echo '<script type="text/javascript"> alert("SAME USER EXISTS")</script>';
}
else if($email[0]=='@')
{
echo '<script type="text/javascript"> alert("invalid email-id")</script>';
}
else if($password!=$cpassword)
{
echo '<script type="text/javascript"> alert("password and confirm password should be identical")</script>';
}
else if(!ctype_digit ( $mnumber ))
{
print '<script type="text/javascript">';
print 'alert("The mobile number cannot contain alphabets")';
print '</script>';
}
else if(strlen($mnumber)!=10)
{
print '<script type="text/javascript">';
print 'alert("The mobile number should be 10 digits")';
print '</script>';
}
else
{
$query="INSERT INTO employer1 (name,username,address,registration,number,email,password,flag) values('$name','$username','$address','$rnumber','$mnumber','$email','$hpass','0')";
$query_run= mysqli_query($con,$query);
echo '<script type="text/javascript"> alert("SUBMITTED")</script>';
if($query_run==true)
{
echo '<script type="text/javascript"> alert("REGISTERED")</script>';
require_once('PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.gmail.com';
$mail->Port = '465';
$mail->isHTML();
$mail->Username = 'smarindia1999@gmail.com';
$mail->Password = 'smarindia99';
$mail->SetFrom('no-reply');
$mail->Subject = 'Hello World';
$mail->Body = 'A test email!';
$mail->AddAddress($email);
if(!$mail->Send())
{
echo '<script type="text/javascript"> alert("Incorrect Email")</script>'; session_destroy();
}
else
{
echo '<script type="text/javascript"> alert("Email sent for verification")</script>';
}
$con= mysqli_connect('localhost','root','') or die('UNABLE TO CONNECT');
//creating company database
$username1=$_POST['username'];
if(!$con)
{
die("cannot connect".mysqli_error());
}
$createdb="CREATE DATABASE $username1";
$createdatabase=mysqli_query($con,$createdb);
if($createdatabase)
{
echo '<script type="text/javascript"> alert("database created")</script>';
}
//$con= mysqli_connect('localhost','root','','$username1') or die('UNABLE TO CONNECT');
//mysqli_select_db($con,'$username1');
$createtb="CREATE TABLE details(
EIN varchar(200),
name text(200),
salary int(200),
mode text(200)
)";
$createtb1=mysqli_query($con,$createtb);
if($createtb1)
{
echo '<script type="text/javascript"> alert("table created")</script>';
}
}
else
{ echo '<script type="text/javascript"> alert("fail")</script>';}
}
}
?>
</body>
</html>