<?php session_start(); include 'info.php'; include 'mail.php'; //CHECK IF THE USER IS LOGGED IN. if (isset($_SESSION['userLoggedIn']) && $_SESSION['userLoggedIn'] == true) { $currentUser = $_SESSION['userUsername']; $currentEmail = $_SESSION['userEmail']; if (getInfo($currentUser, 'hasVerified') == 0) { //CHECK IF USER IS ALREADY VERIFIED. sendVerifyMessage($currentEmail); header("Location: ../portal"); } else { //USER IS ALREADY VERIFIED. header("Location: ../portal"); } } else { header("Location: ../index"); }
<?php session_start(); include 'config.php'; include 'info.php'; include 'mail.php'; //CHECK IF THE REGISTER DETAILS ARE CORRECT. if ($_POST['register_password'] === $_POST['register_cpassword']) { //MYSQL CONNECTION. mysql_connect($serverAddress, $serverUsername, $serverPassword) or die(mysql_error()); mysql_select_db($serverDatabaseName) or die(mysql_error()); $portalUser = $_POST['register_username']; $portalEmail = $_POST['register_email']; $portalName = $_POST['register_fullname']; $portalSalt = md5(chr(mt_rand(ord('a'), ord('z'))) . substr(md5(time()), 1)); $portalHash = md5($_POST['register_password'] . md5($portalSalt)); $portalRegisterIP = getIPAddress(); //MYSQL QUERY. $createUser = "******"; //PERFORM THE FOLLOWING ON A SUCCESSFUL REGISTRATION. if (mysql_query($createUser)) { sendVerifyMessage($portalEmail, $portalUser, $portalName); echo "<script>window.open('../index?error=success&title=Registration%20Success&message=The%20registration%20was%20complete.%20Please%20login%20below','_self')</script>"; //PERFORM THE FOLLOWING ON A FAILED REGISTRATION. } else { echo "<script>window.open('../index?error=danger&title=Failed%20Registration&message=The%20registration%20failed%20to%20complete,%20please%20try%20again%20later','_self')</script>"; } } else { echo "<script>window.open('../index?error=danger&title=Failed%20Registration&message=The%20passwords%20entered%20did%20not%20match','_self')</script>"; }