【发布时间】:2015-04-05 03:24:38
【问题描述】:
我用 PHP 做了一个登录屏幕,但变量“count”为空,而用户名和密码在 oracle 数据库中是正确的。 请帮忙。
我的php代码:(Control.php)
<?php $conn = oci_connect('TEST', 'TEST', 'CODE');
$username1 = $_GET['log']; // textbox name
$password1 = $_GET['pas']; // textbox name
$array = oci_parse($conn, "SELECT MDW_ACHTERNAAM, MDW_VOORNAAM FROM
MDW_VW WHERE MDW_ACHTERNAAM = '" . $username1 . "' AND MDW_VOORNAAM = '" .$password1 ."'");
$query = oci_execute($array);
$count = oci_num_rows($query);
if($count > 0){ // Here is count 0, while the username and password are correct.
header("Opdracht.php");
}
else {
echo "Wrong username.";
}
?>
我的 HTML 代码表单页面:
<form method="get" action="Control.php">
Gebruikersnaam: <br /> <input id="Text1" type="text" name="log" maxlength="8" required /> <br />
Wachtwoord: <br /> <input id="Password1" type="password" name="pas" required /> <br /> <br />
<input id="Submit1" type="submit" value="Inloggen" />
</form>
【问题讨论】:
-
嗨,凯文,欢迎来到 SO!请尝试回显您的 $count 变量并向我们展示内容。
-
@Chilion:会有0,你还期待什么?
-
@panther,可以是一个字符串。
-
@Chilion:来自
oci_num_rows的字符串?也许字符串"1",but "1" > 0在 PHP 中。 -
我回显出我的 $count var,它是 0