title: How to fix Fatal error: Uncaught ArgumentCountError: Too few arguments to function Login::login(), 0 passed?
body: <p>I'm trying to convert my procedural login to OOP but I get ArgumentCountError. This is a project for my homework, can you help me?</p>
  
  <p>Down below is my php code with class and login function and HTML Login page with small php script.</p>
  
  <p>DB Connection is PDO.</p>
  
  <p>When i going to istance my php function with "$login = new Login;
  $login->login($email,$password,$type);" i get this error:</p>
  
  <p>Fatal error: Uncaught ArgumentCountError: Too few arguments to function Login::login(), 0 passed in C:\xampp\htdocs\public_html\project OOP\include\login.php on line 50 and exactly 3 expected in C:\xampp\htdocs\public_html\project OOP\include\login.php:8 Stack trace: #0 C:\xampp\htdocs\public_html\project OOP\include\login.php(50): Login->login() #1 {main} thrown in C:\xampp\htdocs\public_html\project OOP\include\login.php on line 8.</p>
  
  <p>I know that there are a lot of mistakes here, but I'm a beginner.</p>
  
  <pre><code>class Login{
  
     private $email;
     private $password;
     private $type;
  
     public function login($email,$password,$type){
              if(!empty($_POST['email']) &amp;&amp; !empty($_POST['password'])&amp;&amp; !empty($_POST['type'])):
                 switch ($_POST['type']) {
                    case 'Buyer':
                       $records = $conn-&gt;prepare('SELECT * FROM buyer WHERE email = :email');
                       break;
                    case 'Seller':
                       $records = $conn-&gt;prepare('SELECT * FROM seller WHERE email = :email');
                       break;
  
                    default:
                       break;
                 }
                 $_SESSION['type'] = $_POST['type'];
  
                 $records-&gt;bindParam('email', $_POST['email']);
                 $records-&gt;execute();
                 $results = $records-&gt;fetch(PDO::FETCH_ASSOC);
  
                 $message = '';
  
                 if($results &amp;&amp; count($results) &gt; 0 &amp;&amp; md5($_POST['password'], $results['password'])){
                    $_SESSION['user_id'] = $results['buyer_id'];
                    $_SESSION['name'] = $results['buyer_name'];
                    $_SESSION['email'] = $results['email'];
                    $_SESSION['password'] = $results['password'];
                    $_SESSION['phone'] = $results['phone'];
                    $_SESSION['description'] = $results['description'];
                    $_SESSION['status'] = $results['status'];
  
  
                    header("Location: index.php");
                 } else {
                    $message = 'Sorry, those credentials do not match';
                 }  
              endif;
           }
  }
  This is only for test
  $email = "keno1@gmail.com";
  $password = "123456";
  $type = "Buyer";
  
  $login = new Login;
  $login-&gt;login($email,$password,$type);
  
  My HTML code:
  
  &lt;?php
  
  session_start();
  if (  isset($_SESSION['user_id']) ){
  
      header("Location: index.php");
  }
  
  require 'database.php';
  
  
  
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;title&gt;Login V1&lt;/title&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  &lt;!--===============================================================================================--&gt;  
      &lt;link rel="icon" type="image/png" href="images/icons/favicon.ico"/&gt;
  &lt;!--===============================================================================================--&gt;
      &lt;link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css"&gt;
  &lt;!--===============================================================================================--&gt;
      &lt;link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css"&gt;
  &lt;!--===============================================================================================--&gt;
      &lt;link rel="stylesheet" type="text/css" href="vendor/animate/animate.css"&gt;
  &lt;!--===============================================================================================--&gt;  
      &lt;link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css"&gt;
  &lt;!--===============================================================================================--&gt;
      &lt;link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css"&gt;
  &lt;!--===============================================================================================--&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/util.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/login.css"&gt;
      &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"&gt;
      &lt;style type="text/css"&gt;
          body{ font: 14px sans-serif; }
          .wrapper{ width: 350px; padding: 20px; }
      &lt;/style&gt;
  &lt;!--===============================================================================================--&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div class="limiter"&gt;
          &lt;div class="container-login100"&gt;
              &lt;div class="wrap-login100"&gt;
                  &lt;div class="login100-pic js-tilt" data-tilt&gt;
                      &lt;img src="images/img-01.png" alt="IMG"&gt;
                  &lt;/div&gt;
  
                  &lt;form class="login100-form validate-form" action="login.php" method="POST"&gt;
                      &lt;span class="login100-form-title"&gt;
                          Member Login
                      &lt;/span&gt;
                      &lt;div class="wrap-input100 validate-input" data-validate = "Valid email is required: ex@abc.xyz"&gt;
                          &lt;input class="input100" type="text" name="email" placeholder="Email"&gt;
                          &lt;span class="focus-input100"&gt;&lt;/span&gt;
                          &lt;span class="symbol-input100"&gt;
                              &lt;i class="fa fa-envelope" aria-hidden="true"&gt;&lt;/i&gt;
                          &lt;/span&gt;
                      &lt;/div&gt;
  
                      &lt;div class="wrap-input100 validate-input" data-validate = "Password is required"&gt;
                          &lt;input class="input100" type="password" name="password" placeholder="Password"&gt;
                          &lt;span class="focus-input100"&gt;&lt;/span&gt;
                          &lt;span class="symbol-input100"&gt;
                              &lt;i class="fa fa-lock" aria-hidden="true"&gt;&lt;/i&gt;
                          &lt;/span&gt;
                      &lt;/div&gt;
                      &lt;select class="browser-default custom-select" name="type"&gt;
                          &lt;option disabled="disabled" selected="selected"&gt;Profile type&lt;/option&gt;
                          &lt;option&gt;Buyer&lt;/option&gt;
                          &lt;option&gt;Seller&lt;/option&gt;
                      &lt;/select&gt;
                      &lt;div class="container-login100-form-btn"&gt;
                          &lt;button class="login100-form-btn" type="submit" name="submit"&gt;
                              Login
                          &lt;/button&gt;
                      &lt;/div&gt;
  
                      &lt;div class="text-center p-t-12"&gt;
                          &lt;span class="txt1"&gt;
                              Forgot
                          &lt;/span&gt;
                          &lt;a class="txt2" href="#"&gt;
                              email / Password?
                          &lt;/a&gt;
                      &lt;/div&gt;
  
                      &lt;div class="text-center p-t-136"&gt;
                          &lt;a class="txt2" href="register.php"&gt;
                              Create your Account
                              &lt;i class="fa fa-long-arrow-right m-l-5" aria-hidden="true"&gt;&lt;/i&gt;
                          &lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;  
  &lt;!--===============================================================================================--&gt;  
      &lt;script src="vendor/jquery/jquery-3.2.1.min.js"&gt;&lt;/script&gt;
  &lt;!--===============================================================================================--&gt;
      &lt;script src="vendor/bootstrap/js/popper.js"&gt;&lt;/script&gt;
      &lt;script src="vendor/bootstrap/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;!--===============================================================================================--&gt;
      &lt;script src="vendor/select2/select2.min.js"&gt;&lt;/script&gt;
  &lt;!--===============================================================================================--&gt;
      &lt;script src="vendor/tilt/tilt.jquery.min.js"&gt;&lt;/script&gt;
      &lt;script &gt;
          $('.js-tilt').tilt({
              scale: 1.1
          })
      &lt;/script&gt;
  &lt;!--===============================================================================================--&gt;
      &lt;script src="js/main.js"&gt;&lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>