I have a login form and i want to enter username & password to log into the system.
When loading the page (index.php) there was an error displayed like this.
Notice: Undefined index: msg in C:\wamp\www\Home page\new student registration\index.php on line 13
index.php
<form id="form1" name="form1" method="post" action="adminloginvalidate.php">
<?php
$message=$_POST["msg"]; [B][line 13][/B]
?>
<table width="499" align="center">
<tr>
<td width="520" height="125" valign="top"> </td>
</tr>
<tr>
<td height="284" valign="top" background="images/logo_image.png"><table width="468" border="0">
<tr>
<td width="28"> </td>
<td width="58"> </td>
<td colspan="2"> </td>
<td width="150"> </td>
<td width="89"> </td>
<td width="14"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="5" align="center"><label><strong>STUDENT MANAGEMENT SYSTEM</strong></label> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="5" align="center">Subarathi Vidyalaya Godagama</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="5" align="center"><label>Please enter your user name and password</label> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"><label>User Name</label>
</td>
<td>
<label>
<input type="text" name="username" id="textfield" />
</label>
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"><label>Password</label> </td>
<td>
<label>
<input type="password" name="password" id="textfield2" />
</label>
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"> </td>
<td>
<label>
<input type="submit" name="button" id="button" value="Login" />
</label>
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="5"><span style="color:#F00"><?php echo $message; ?></span></td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
adminloginvalidate.php
<?php
$username=$_POST["username"];
$password=$_POST["password"];
$con=mysql_connect("localhost","root","");
mysql_select_db("student_management",$con);
$query="SELECT count(*) FROM administrator
where username='$username' and password='$password'";
$result=mysql_query($query);
while($row = mysql_fetch_array($result))
{
$answer=$row[0];}
if($answer!=0){
session_start();
$_SESSION['username']=$username;
$_SESSION['state']="admin";
header("location:../../add admin users/add techer/addAdminterpage.php");
exit();
}else{
header("location:index.php?msg=your username password is incorrect");
exit();
}
?>