Ich kann dir zu deinem Problem so direkt jetzt nichts sagen, aber das hier finde ich etwas merkwürdig:
<form name="form" method="post" action="index.php?pid=<? echo $pid; ?>&<?=SID?>">
<p>passwort:<br>
<input type="password" name="pass">
<input type="submit" name="submit" value="log-in">
</form>
Ich kann mir nicht vorstellen, dass diese Angabe von action wirklich gut funktioniert.
Ich würde das eher so schreiben:
<form name="form" method="post"action="index.php">
<input type="hidden" name="pid" value="<? echo $pid; ?>">
...
[und der Rest...]
Versuch mal, vielleicht hilft es dir ja auch bei deinem Problem weiter.
cYa