trying to learn php and first project I am attempting is a pm system but I keep getting an error that says Notice: Undefined index: userid in login.php on line 102 & line 110

hope someone can help i am starting to like php 

source code

line 102

```
$nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where
((user1="'.$_SESSION['userid'].'" and user1read="no") or
(user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"'));

```

line 110

```
<a href="list_pm.php">Your messages(<?php echo $nb_new_pm; ?>)</a> - 
<a href="profile.php?id=<?php echo $_SESSION['userid']; ?>">
<?php echo htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8'); ?></a> 
(<a href="login.php">Logout</a>)

```