This question already has an answer here:
I have error when a user login
whats wrong?
in first time tell me welcome but after refresh page tell me error:
Notice: Undefined variable : username in index.php on line 175
<?php
$fn=2;
if(isset($_POST["smbit"])){
$fn=1;
$username = $_POST['username'];
$password = md5($_POST['password']);
$res=mysql_query("SELECT userid,isadmin FROM users WHERE user='$_POST[username]' and pass='$_POST[password]'",$cn);
if($row=mysql_fetch_object($res)){
$fn=0;
mysql_query("UPDATE session SET islogin=1,isadmin=$row->isadmin,uid='$row->userid' where sid='$sid'");
}
}
if($islogin==1) $fn=0;
if($fn==1) echo "<b>Login Not Found!</b>";
if($fn==1 || $fn==2){
?>
<p></p>
<form action="index.php" method="post">
<i>Username:</i><input type="text" name="username"/>
<i>Password:</i><input type="password" name="password">
<input class="buttom" type="submit" name="smbit" value="Login">
</form>
<a href="register.php">Not Register?</a>
<p></p>
<?php
}
if($fn==0) echo "<h3 align=center>Welcome $username</h3><h4><a href=logout.php>Log out</a> </h4>";
?>
</div>