else{
  echo "Password should not be empty";
  die();
}

i want to hide a button

here is the full code using mysql data with phpmyadmin on online server (not localhost)

<!DOCTYPE html> <html> <head> <title></title> </head> <body> <form> <input type="button" onclick="location.href='/question1.php';" value="Go to question1" id="button"> </form> </body> </html> <?php
$username = filter_input(INPUT_POST, 'username');
 $password = filter_input(INPUT_POST, 'password');
 if (!empty($username)){
if (!empty($password)){
$host = "------";
$dbusername = "------";
$dbpassword = "------";
$dbname = "-----";

// Create connection
$conn = new mysqli ($host, $dbusername, $dbpassword, $dbname);

if (mysqli_connect_error()){
  die('Connect Error ('. mysqli_connect_errno() .') '
    . mysqli_connect_error());
}
else{
  $sql = "INSERT INTO account (username, password)
  values ('$username','$password')";
  if ($conn->query($sql)){
    echo "";
  }
  else{
    echo "Error: ". $sql ."
". $conn->error;
  }
  $conn->close();
}
}
else{
  echo "Password should not be empty";
  die();
}
 }
 else{
  echo "Username should not be empty";
  die();
 }
?>

so can i add a javascript or anything to hide when username or password is empty?

ALARMS! Line 19 shows a common gaffe in login and registration systems. Here's the rule.

Never store passwords in a database.

It's just not done. If this is for your school project, I'd mark it down for this. I can't write what a bad idea this is.
Here's how you can research how to do it right.
https://www.google.com/search?q=never+store+passwords+in+a+database

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.