<?php

	include "library.php";

	$cxn = start_code();
	
	$cxn_common = db_common_login();
	

			/* 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";

	$_SESSION['sitename'] = "International Businesses For Sale";

	page_header( "", $cxn, $cxn_common, "", 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 account_id FROM account WHERE account_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 account SET email_address_verified = 'yes' WHERE account_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();
	}
?>

