Location: PHPKode > projects > ProjectPress > projectpress/activate.php
<?php 
session_start(); //Starts the session.
define('access',true);
include('config.inc.php');
include(PM_DIR . 'pm-includes/global.inc.php');
require(PM_DIR . 'pm-includes/functions.php');

foreach($_GET as $key => $value) {
	$get[$key] = pmdb::connect()->escape($value);
}

/******** EMAIL ACTIVATION LINK**********************/
if(isset($get['user']) && !empty($get['activ_code']) && !empty($get['user']) && is_numeric($get['activ_code']) ) {

$err = array();
$msg = array();

$user = pmdb::connect()->escape($get['user']);
$activ = pmdb::connect()->escape($get['activ_code']);

//check if activ code and user is valid
$rs_check = pmdb::connect()->query("SELECT user_id FROM " . DB . "members WHERE md5_id='$user' AND activation_code='$activ'"); 
$num = $rs_check->num_rows;
  // Match row found with more than 1 results  - the user is authenticated. 
    if ( $num <= 0 ) { 
	$err[] = "Sorry no such account exists or activation code invalid.";
	//header("Location: activate.php?msg=$msg");
	//exit();
	}

if(empty($err)) {
// set the approved field to 1 to activate the account
$rs_activ = pmdb::connect()->query("UPDATE " . DB . "members set active = '1' WHERE 
						 md5_id='$user' AND activation_code = '$activ' ");
$msg[] = "Thank you. Your account has been activated.";
//header("Location: activate.php?done=1&msg=$msg");						 
//exit();
 }
}

/******************* ACTIVATION BY FORM**************************/
if ($_POST['doActivate']=='Activate')
{
$err = array();
$msg = array();

$user_email = pmdb::connect()->escape($_POST['user_email']);
$activ = pmdb::connect()->escape($_POST['activ_code']);
//check if activ code and user is valid as precaution
$rs_check = pmdb::connect()->query("SELECT user_id FROM " . DB . "members WHERE email='$email' AND activation_code='$activ'"); 
$num = $rs_check->num_rows;
  // Match row found with more than 1 results  - the user is authenticated. 
    if ( $num <= 0 ) { 
	$err[] = "Sorry no such account exists or activation code invalid.";
	//header("Location: activate.php?msg=$msg");
	//exit();
	}
//set approved field to 1 to activate the user
if(empty($err)) {
	$rs_activ = pmdb::connect()->query("UPDATE " . DB . "members SET active = '1' WHERE 
						 email='$email' AND activation_code = '$activ' ");
	$msg[] = "Thank you. Your account has been activated.";
 }
//header("Location: activate.php?msg=$msg");						 
//exit();
}

	

?>
<html>
<head>
<title>User Account Activation</title>
<meta http-equiv="Content-Type" content="text/html; UTF-8">
<link href="<?php echo PM_URI ?>/css/login-style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript" src="<?php echo PM_URI; ?>/js/jquery-1.3.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="<?php echo PM_URI; ?>/js/jquery.validate.js"></script>
  <script>
  $(document).ready(function(){
    $("#actForm").validate();
  });
  </script>
</head>

<body>
<div id="register">
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr> 
    <td width="160" valign="top"><p>&nbsp;</p>
      <p>&nbsp; </p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p></td>
    <td width="732" valign="top">
<h3 class="titlehdr">Account Activation</h3>

      <p> 
        <?php
	  /******************** ERROR MESSAGES*************************************************
	  This code is to show error messages 
	  **************************************************************************/
	if(!empty($err))  {
	   echo "<div class=\"msg\">";
	  foreach ($err as $e) {
	    echo "* $e <br>";
	    }
	  echo "</div>";	
	   }
	   if(!empty($msg))  {
	    echo "<div class=\"msg\">" . $msg[0] . "</div>";

	   }	
	  /******************************* END ********************************/	  
	  ?>
      </p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>Please enter your email and activation code sent to you to your email 
        address to activate your account. Once your account is activated you can 
        <a href="login.php">login here</a>.</p>
	 
      <form action="activate.php" method="post" name="actForm" id="actForm" >
        <table width="65%" border="0" cellpadding="4" cellspacing="4" class="loginform">
          <tr> 
            <td colspan="2">&nbsp;</td>
          </tr>
          <tr> 
            <td width="36%">Your Email</td>
            <td width="64%"><input name="email" type="text" class="required email" id="txtboxn" size="25"></td>
          </tr>
          <tr> 
            <td>Activation code</td>
            <td><input name="activ_code" type="password" class="required" id="txtboxn" size="25"></td>
          </tr>
          <tr> 
            <td colspan="2"> <div align="center"> 
                <p> 
                  <input name="doActivate" type="submit" id="sub_button" value="Activate">
                </p>
              </div></td>
          </tr>
        </table>
        <div align="center"></div>
        <p align="center">&nbsp; </p>
      </form>
	  
      <p>&nbsp;</p>
	 
      </td>
    <td width="196" valign="top">&nbsp;</td>
  </tr>
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
</table>
</div>
</body>
</html>
Return current item: ProjectPress