<?php 
include "config.php";
mysql_connect ($dbhost, $username, $password);
mysql_select_db ($maindb);
$to=$_GET['to'];
$from=$_GET['from'];
//echo "to=$to, from=$from";
$result = mysql_query("SELECT * FROM t1 WHERE id='$from';");
$name = mysql_result ($result, 0, 1);
$rank = mysql_result ($result, 0, 2);
$tel =  mysql_result ($result, 0, 3);
$mail = mysql_result ($result, 0, 4);
$room = mysql_result ($result, 0, 5);
$dep =  mysql_result ($result, 0, 6);
$perm = mysql_result ($result, 0, 7);

$result = mysql_query("SELECT * FROM t1 WHERE id='$to';");
$name2 = mysql_result ($result, 0, 1);
$rank2 = mysql_result ($result, 0, 2);
$tel2 =  mysql_result ($result, 0, 3);
$mail2 = mysql_result ($result, 0, 4);
$room2 = mysql_result ($result, 0, 5);
$dep2 =  mysql_result ($result, 0, 6);
$perm2 = mysql_result ($result, 0, 7);

mysql_query("UPDATE t1 SET name='$name', rank='$rank', tel='$tel', mail='$mail', room='$room', dep='$dep', perm='$perm' WHERE id='$to';");
mysql_query("UPDATE t1 SET name='$name2', rank='$rank2', tel='$tel2', mail='$mail2', room='$room2', dep='$dep2', perm='$perm2' WHERE id='$from';");

mysql_close();
?>
