Server IP : 68.65.122.142  /  Your IP : 3.137.167.89
Web Server : LiteSpeed
System : Linux server167.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User : glenirhm ( 1318)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/glenirhm/mygc.glenbowcollege.ca/student/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/glenirhm/mygc.glenbowcollege.ca/student/activate.php
<?php
include('../common/send_email.php');
include('../common/connect.php');
// First we check if the email and code exists...
if (isset($_GET['email'], $_GET['code'])) {
	if ($stmt = $con->prepare('SELECT * FROM student WHERE email = ? AND activation_code = ?')) {
		$stmt->bind_param('ss', $_GET['email'], $_GET['code']);
		$stmt->execute();
		// Store the result so we can check if the account exists in the database.
		$stmt->store_result();
		if ($stmt->num_rows > 0) {
			// Account exists with the requested email and code.
			if ($stmt = $con->prepare('UPDATE student SET activation_code = ? WHERE email = ? AND activation_code = ?')) {
				// Set the new activation code to 'activated', this is how we can check if the user has activated their account.
				$newcode = 'activated';
				$stmt->bind_param('sss', $newcode, $_GET['email'], $_GET['code']);
				$stmt->execute();
				echo 'The account is now activated! The student can now <a href="index.html">login</a>!';

				// Send email to the student
				sendEmail($EMAIL_HOST, $EMAIL_USERNAME, $EMAIL_PASS, $EMAIL_FROM, $_GET['email'], 'Your account has been activated', 'You can now <a href="https://' . dirname($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) .'/index.html">login</a>!', '', null);
			}
		} else {
			echo 'The account is already activated or doesn\'t exist!';
		}
	}
}
?>