PHP-为什么可以';t我把资料插入我的表中


PHP - Why can't I insert information into my table?

我正试图使用类和函数将信息插入到表中。

我不知道为什么,但我的功能不起作用。虽然它能识别我的数据库,但当我提交表单时,它会发出错误消息

我需要更改什么?

这是我的表单页面代码:

<?php
include("BDMySQL.class.php");
?>
<html>
<head>
    <title>Registo</title>
    <link rel="stylesheet" href="css/style.css" type="text/css"/>   
</head>
<body>
    <span id="background"></span>
    <div id="page">
        <div id="sidebar">
            <div id="logo">
                <a href="index.html">Apenas as melhores da <em>BlastingBeats Rec.</em></a>
            </div>
            <ul id="navigation">
            <li><a href="Index.html">Home</a></li>
                <li class="selected"><a href="login.html">Login</a></li>
                <li><a href="registo.html">Registar</a></li>
            </ul>
            <ul id="connect">
                <li><a href="http://facebook.com/freewebsitetemplates" target="_blank" class="facebook"></a></li>
                <li><a href="http://twitter.com/fwtemplates" target="_blank" class="twitter"></a></li>
                <li><a href="" class="link-us"></a></li>
            </ul> 
            <div class="footer">
                &copy; Copyright &copy; 2011.<br/>
                <a href="index.html">Company name</a> all rights reserved.
            </div>
        </div>
        <div id="contents">
        <ul class="images">


        <?php
if($_POST['Nome']=="") {
?>
        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"><p>
        Nome de Utilizador:<p>
        <input type="text" name="Nome"></input><p>
        Palavra-Passe:<p>
        <input type="text" name="Pass"></input><p>
        <input type="submit" class="button"><p>
        </form>
        <?php
}
else {
?>
<?php
include("Cliente.class.php");
                            $Cliente = new Cliente();
                            if($Cliente->introduzirCliente($_REQUEST['Nome'], $_REQUEST['Pass'])) {
                                echo "Registo efectuado com sucesso !!!<br>";
                            } else {
                                echo "Problema encontado no Registo !!!<br>";
                                echo mysql_errno() . "'n";
                            }
                        $Cliente->endCliente();

}
?>

            </ul>
        </div> 
    </div> 
</body>
</html>

我的功能代码:

function introduzirCliente($Nome, $Pass) {

            $sql = "INSERT INTO clientes VALUES ('$Nome' , '$Pass')";
            if($this->bd->executarSQL($sql)) return true;
            else return false;
        }

我假设客户端数据库表中有两个以上的字段。因此,您需要将sql行从以下位置更改:

$sql = "INSERT INTO clientes VALUES ('$Nome' , '$Pass')";

类似于:

$sql = "INSERT INTO clientes (username, password) VALUES ('$Nome','$Pass')";

其中,您可以在正确的字段名称中替换用户名和密码。