<?php

	include "library.php";

	$cxn = start_code();

	$cxn_common = db_common_login();


	
			/* get variables */

	$id = val( $_SESSION, "id" );

	$photo_number = val( $_GET, "photonumber" );


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

		/* check the parameters  */

	crash_if_missing( $id, "id is not set in set primary photo", $cxn );

	crash_if_missing( $photo_number, "photo number is not set in set primary photo", $cxn );

		/* get the file extension */

	$query = "UPDATE photos SET primary_photo = 'no' WHERE member_id = ".$id;

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

	$query = "UPDATE photos SET primary_photo = 'yes' WHERE member_id = ".$id." AND photo_number = ".$photo_number;

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

	echo black( "<br>Photo successfully set as your primary photo<br><br><br>" );

	echo show_link( "Return", "manage_photos.php" );

?>