-
Notifications
You must be signed in to change notification settings - Fork 1
/
wbsign-up.php
157 lines (137 loc) · 4.14 KB
/
wbsign-up.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
<?php
session_start();
include 'config.php'
?>
<?php
$error="";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$memno = $_POST['memno'];
$dob = $_POST['dob'];
$sex = $_POST['sex'];
$company = $_POST['company'];
$sapid = $_POST['sapid'];
//print $memno;
//print $dob;
//print $sex;
//print $company;
//print $sapid;
$profiles = $conn->query("SELECT * FROM profiles WHERE MemNo = '$memno' AND DOB = '$dob' AND Sex = '$sex' AND SAPID = '$sapid' ");
$row = $profiles -> fetch_assoc();
// Return the number of rows in result set
$rowcount = mysqli_num_rows($profiles);
if($rowcount<1){
printf ("Details not matching with our records. Please check.");
} else{
//printf ("Welcome %s (%d) %s\n", $row["Name"], $row["MemNo"], $row["Email"]);
$profiles1 = $conn->query("SELECT * FROM Wbusers WHERE MemNo = '$memno' ");
$rowcount1 = mysqli_num_rows($profiles1);
echo $rowcount1;
$n=6;
function getName($n) {
$characters = '0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ';
$randomString = '';
for ($i = 0; $i < $n; $i++) {
$index = rand(0, strlen($characters) - 1);
$randomString .= $characters[$index];
}
return $randomString;
}
$randno=getName($n);
echo $randno;
$dt = date('m/d/Y h:i:s a', time());
//echo $dt;
if($rowcount1<1){
$mailtext = "Your One Time Password (OTP) to Register in wbsefama.org is ";
$profiles2 = $conn->query("INSERT INTO Wbusers (MemNo, OTP, OTPTime) VALUES ('$memno', '$randno', '$dt'); ");
} else{
$mailtext = "Your One Time Password (OTP) to Reset password in wbsefama.org is ";
$sql = $conn->query("UPDATE Wbusers SET OTP='$randno', OTPTime='$dt' WHERE MemNo = '$memno'");
}
$to = $row["Email"];
$subject = "WBSEF&AMA Login OTP (do not reply)";
$message = "Dear Member,";
$message .= "<p>$mailtext";
$message .= $randno;
// $message .= ".";
$message .= "<p>This OTP is valid for next 10 minutes only.";
$message .= "<p>Web service team, WBSEF&AMA";
$header = "From:[email protected] \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully. Please check your registered mail ID for OTP..";
header("location:wbsetpwd.php");
}else {
echo "Message could not be sent...";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>WBSEF&AMA</title>
<link rel="stylesheet" type="text/css" href="CSS/StylesMain.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0">
<script type="text/javascript" src="JavaScript/ScriptMain.js"></script>
</head>
<body>
<?php include 'sidebar.php' ?>
<div class="content">
<div class="form-container">
<h2>Sign Up</h2>
<form
method="post"
action="<?php
echo htmlspecialchars($_SERVER['PHP_SELF'])
;?>"
>
<div>
<label for="memno">Membership No.</label>
<input
type="integer"
name="memno"
id="memno"
required
>
</div>
<div>
<label for="dob">Date of Birth</label>
<input
type="date"
name="dob"
id="dob"
>
</div>
<div>
<label for="sex">Sex</label>
<select name="sex" id="sex">
<option value="" hidden></option>
<option value="F">Female</option>
<option value="M">Male</option>
</select>
</div>
<div>
<label for="SAPID">SAP ID</label>
<input
type="tel"
name="sapid"
id="sapid"
required
>
</div>
<div>
<input type="submit" value="Proceed">
<?php echo $error ?>
</div>
</form>
</div>
Already have an account? <a href="./login.php">Login</a>
</div>
</div>
</div>
</body>
</html>