Help in php / phpmyadmin

Hello, im trying to create php code for my login page. It continuously shows incorrect password even if the password on the database is correct.

  • PLEASE HELP
<?php
   
   $dbhost = 'localhost:3306';
   $dbuser = 'root';
   $dbpass = '*********************';
   $conn = mysql_connect($dbhost, $dbuser, $dbpass);
   
   if(! $conn ) {
      die('Could not connect: ' . mysql_error());
   }
   else {
	if(isset($_POST['username']))
	{
        	$username= $_POST['username'];
        	$password= $_POST['password'];
        	$sql="select * from loginform where username='$username'AND password='$password'";
        	$result=mysql_query($sql);
    
    		if(mysql_num_rows($result)==1)
		{
        		echo " You Have Successfully Logged in";
        		exit();
    		}
    		else 
		{
        		echo " incorrect password";
        		exit();
    		}
        
   	}
  }
?>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums