我这里有一个我正在处理的登录,我认为我的PHP存在一个小问题。
我的php连接到DB:
<?php
$db_name = "mydata";
$mysql_username = "root";
$mysql_password = "";
$server_name = "localhost";
$conn = mysqli_connect($server_name, $mysql_username, $mysql_password, $db_name);
if($conn){
echo
"Connection Succesful";
}
else{
echo "Connection Not Succesful";
}
?>
我的php用于实际登录:
<?php
require "conn.php";
$Email = $_POST["emailPost"];
$Password = $_POST["passwordPost"];
$sql = "SELECT Password FROM users WHERE Email = '".$Email."' ";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result)){
if($row == $Password){
echo "login success";
}
else{
echo "Password incorrect";
}
}
}else{
echo "user not found";
}
?>
最后是我在C#中使用的Coroutine
IEnumerator LoginAccount()
{
WWWForm Form = new WWWForm();
Form.AddField("emailPost", Email);
Form.AddField("passwordPost", Password);
WWW www = new WWW(LoginUrl, Form);
yield return www;
Debug.Log(www.text);
}
我每次都得到Password incorrect
。我错过了什么?
答案 0 :(得分:0)
var app = require('../app');
var debug = require('debug')('goWeb:server');
var http = require('http');
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
答案 1 :(得分:-1)
使用此代码(确保将此$row[Password]
更新为与密码字段名称相同)
<?php
require "conn.php";
$Email = $_POST["emailPost"];
$Password = $_POST["passwordPost"];
$sql = "SELECT Password FROM users WHERE Email = '".$Email."' ";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result)>0)
{
while($row = mysqli_fetch_assoc($result))
{
if($row['Password'] == $Password)
{
echo "login success";
}
else
{
echo "Password incorrect";
}}}
else
{
echo "user not found";
}
?>