我想傳遞一個參數到一個PHP函數 但是什麼都沒有發生,我的意思是代碼沒有通過index.php paramater到newPHPClass.php 和是否有可能調用一個函數形式的行動? 這裏是我的代碼。試圖通過一個參數,不工作:(
的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);
}
?>
和類
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;
}
}
-1有什麼問題? – sachleen