<?php

	include "library.php";

	$cxn = start_code();


			/* get variables */

	$verifyid = val( $_GET, "verifyid" );

	$code = val( $_GET, "code" );


		/* kill anything hanging around in the URL etc as this is an external entry point */

	session_destroy();

	session_start();

	$_SESSION['session_active'] = "yes";

	
	page_header( "", $cxn, "", true );


		/* check parameters */

	crash_if_missing( $verifyid, "verify id missing in verify email address", $cxn );

	crash_if_missing( $code, "verification code missing in verify email address", $cxn );


		/* look for member */

	$query = "SELECT id FROM profile WHERE id = ".$verifyid." AND email_verification_code = '".$code."'";

	if (! query_has_rows( $query, $cxn ) )
		echo black( "Invalid parameters" );
	else
	{
//		$query = "UPDATE profile SET locked = 'no' WHERE id = ".$verifyid;
//		$result = run_query( $query, $cxn );

		$query = "UPDATE profile SET email_address_valid = 'yes', returned_mail = 'no' WHERE id = ".$verifyid;

		$result = run_query( $query, $cxn );

		echo black( "Email address verified<br><br>Your account has been activated<br><br>" );

		echo show_home_link();
	}
?>

