whats really causing this undefined variable
<p>i know the best approach when programming is not to disable errors,i have been getting a series of errors ever since i started making my simple web forum,i have tried to get ride of some but i am having a problem with some,the <code>undefined variable</code> is the most common error and it seems like i have to declare some like <code>A='';</code> then <code>A=values;</code>  for example but i have no idea how i can tackle this one below</p>

<pre><code>Notice: Undefined variable: act in C:\xampp\htdocs\mysite\forum part two\login.php on line 74
</code></pre>

<p>the code on line 74 is this</p>

<pre><code>case "login";
</code></pre>

<p>and my other code where there is <code>login</code> is this in the <code>login.php</code></p>

<pre><code>switch($act){

default;
index();
break;

case "login";
login();
break;

}
</code></pre>

<p>my code on the <code>login.php</code> is this</p>

<pre><code>&lt;?php
session_start();
//This displays your login form
function index(){
echo "&lt;form action='?act=login' method='post'&gt;" 
    ."Username: &lt;input type='text' name='username' size='30'&gt;&lt;br&gt;"
    ."Password: &lt;input type='password' name='password' size='30'&gt;&lt;br&gt;"
    ."&lt;input type='submit' value='Login'&gt;"
    ."&lt;/form&gt;";    
}
//This function will find and checks if your data is correct
function login(){
//Collect your info from login form
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
//Connecting to database
$connect = mysql_connect("localhost", "root", "nokiae71");
if(!$connect){
die(mysql_error());
}
//Selecting database
$select_db = mysql_select_db("forumStructure", $connect);
if(!$select_db){
die(mysql_error());
}
//Find if entered data is correct
$result = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
$row = mysql_fetch_array($result);
$id = $row['id'];
$select_user = mysql_query("SELECT * FROM users WHERE id='$id'");
$row2 = mysql_fetch_array($select_user);
$user = $row2['username'];

if($username != $user){
die("Username is wrong!");
}
$pass_check = mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id'");
$row3 = mysql_fetch_array($pass_check);
$email = $row3['email'];
$select_pass = mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id' AND email='$email'");
$row4 = mysql_fetch_array($select_pass);
$real_password = $row4['password'];
if($password != $real_password){
die("Your password is wrong!");
}
//Now if everything is correct let's finish his/her/its login
session_register("username", $username);
session_register("password", $password);
echo "Welcome, ".$username." please continue on our &lt;a href=index.php&gt;Index&lt;/a&gt;";
}

switch($act){
default;
index();
break;
case "login";
login();
break;
}
?&gt; 
</code></pre>
