I am trying to pass a parameter to a php function. But nothing is happening, I mean the code does not pass the paramater in index.php to newPHPClass.php and is it possible to call a function in the form action? here is my code.
index.php
<?php include '../con_db/connect.php'; ?>
<?php include '../class/newPHPClass.php'; ?>
<form action="index.php" method="post">
<label>Username:</label><input type="text" name="username"/><br/>
<label>Password:</label><input type="text" name="password"/><br/>
<input type="submit" value="Submit" name="submit"/>
</form>
<?php
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$check = new newPHPClass();
$check->checkLogin($username, $password);
}
?>
and the class
include '../con_db/connect.php';
class newPHPClass {
public function checkLogin($username, $password) {
$select = mysql_query('SELECT * FROM users WHERE username = "' . $username . '" AND password = "' . $password . '"');
if (count($select) > 0) {
echo "true";
return true;
} else {
echo "false";
return false;
}
}