Im trying to send a data containing username, password etc from a HTML form-> ajax -> instance -> oop class file.
But im not sure i have the right approach...
It starts with the form on index.php
 <!-- Formular for signing up -->
 <form method="post">
    <div class="form-group">
        <label> Username </label>
        <input type="text" class="form-control" name="newusername"> 
    </div>    
    <div class="form-group">
        <label> Password </label>
        <input type="password" class="form-control" name="newpassword"> 
    </div>
    <div class="form-group">
        <label> Your club </label>
        <input type="text" class="form-control" name="newclub"> 
    </div>   
   <input type="button" id="btn-reg" class="btn btn-success" value="Sign up!">
</form> 
And then it goes trough my script file and ajax
$(document).ready(function () {
console.log('Script loaded...');
$("#btn-reg").on("click", reg);      
// Function for registrate of new users
function reg(newusername, newpassword, newclub) {
    $.post('classCalling.php', {
        newusername: 'newusername',
        newpassword: 'newpassword',
        newclub: 'newclub'
    });
};
});
And then my data is going to a page, classCalling.php where i instance my class
    ?php
     include("class/userClass.php");
     include("class/pagesClass.php");
                // Creating instance of the class userClass.php
                 $user = new User();
                // Defining variables
                $newusername = $_POST['newusername'];
                $newpassword = $_POST['newpassword'];
                $newname = $_POST['newclub'];
                // Password hash
                $hashpassword = sha1($newpassword);
                $user->newUsers($newusername, $hashpassword, $newname);         
 ?>
And finaly my OOP Class, but im not getting this far
 public function newUsers($newusername, $newpassword, $newclub) {
        // Using prepared statement to prevent mysql injections.
        $stmt = $this->db->prepare("INSERT INTOusers(username,password, club)VALUES(?, ?, ?);");
        $stmt->bind_param("sss", $newusername, $newpassword, $newclub);
        if($stmt->execute()) {
            echo "<h3 class='usercreated'>Användare skapad</h3>";
            } else {
                echo "<h3 class='usercreated'> Gick ej att skapa användare</h3>";
            }
}
Im getting these errors Notice: Undefined index: newusername in /Applications/MAMP/htdocs/web 2.0/projektet/classCalling.php on line 13
 
     
     
     
     
    