Hi, i do some code in order to learn login function and i find the code from internet, but when i run the code this error is appear
>>Warning: mysql_fetch_arr ay() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs \login2\login.p hp on line 12
I do not know what the problem is, can someone help me please?
>>Warning: mysql_fetch_arr ay() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs \login2\login.p hp on line 12
I do not know what the problem is, can someone help me please?
Code:
<?php include("config.php"); session_start(); if($_SERVER["REQUEST_METHOD"] == "POST") { // username and password sent from Form $myusername=addslashes($_POST['username']); $mypassword=addslashes($_POST['password']); $sql="SELECT id FROM admin WHERE username='$myusername' and passcode='$mypassword'"; $result=mysql_query($sql); $row=mysql_fetch_array($result); $active=$row['active']; $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1) { session_register("myusername"); $_SESSION['login_user']=$myusername; header("location: welcome.php"); } else { $error="Your Login Name or Password is invalid"; } } ?> <form action="" method="post"> <label>UserName :</label> <input type="text" name="username"/><br /> <label>Password :</label> <input type="password" name="password"/><br/> <input type="submit" value=" Submit "/><br /> </form>
Comment