diff options
author | arf20 <aruizfernandez05@gmail.com> | 2024-03-16 02:51:06 +0100 |
---|---|---|
committer | arf20 <aruizfernandez05@gmail.com> | 2024-03-16 02:51:06 +0100 |
commit | da57beb574fb9f756a7de036e8003f75ec47432c (patch) | |
tree | b34bba686432f972816bb649d47431fcd2efa66e /register.php | |
parent | ecdcfff2460db708ae4b471140335ce47aaaf54b (diff) | |
download | arfnet2-cstims-da57beb574fb9f756a7de036e8003f75ec47432c.tar.gz arfnet2-cstims-da57beb574fb9f756a7de036e8003f75ec47432c.zip |
Email verification
Diffstat (limited to 'register.php')
-rwxr-xr-x | register.php | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/register.php b/register.php index 37565c5..3ef957a 100755 --- a/register.php +++ b/register.php @@ -1,13 +1,28 @@ <?php
+// Dependency
+
+function send_verification_email($rcpt, $code) {
+ global $mailer;
+ $mailer->addAddress($rcpt);
+ $mailer->Subject = 'ARFNET Email Verification';
+ $mailer->Body = "Welcome to ARFNET\n\nUse the following link to verify your email address\n\n"
+ ."https://".DOMAIN."/verify.php?code=".$code
+ ."\n\n--\nARFNET Client, Service, Ticket and Invoice Management System\nhttps://arf20.com";
+ if (!$mailer->send()) {
+ echo 'Mailer Error [ask arf20]: ' . $mailer->ErrorInfo;
+ }
+}
+
// Include config file
require_once "config.php";
// Define variables and initialize with empty values
$username = $password = $confirm_password = $email = "";
$username_err = $password_err = $confirm_password_err = $email_err = "";
+$verification_mail_sent = false;
// Processing form data when form is submitted
-if ($_SERVER["REQUEST_METHOD"] == "POST"){
+if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Validate username
if (empty($_POST["username"]))
$username_err = "Enter a username.";
@@ -84,7 +99,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST"){ // Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
// Send verification email
-
+ send_verification_email($email, $param_verifycode);
+ $verification_mail_sent = true;
// Redirect to login page
header("location: login.php");
} else {
@@ -142,6 +158,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST"){ <input type="submit" class="btn btn-primary" value="Submit">
</div>
<p><a href="login.php">Login</a>.</p>
+ <?php if ($verification_mail_sent) echo 'Verification email sent.'; ?>
</form>
</div>
</main>
|