c#csharp/php/mysql连接
在c#中: 如果单击该按钮,函数将执行 单击按钮后,在PHP中:c#csharp/php/mysql连接,c#,php,C#,Php,在c#中: 如果单击该按钮,函数将执行 单击按钮后,在PHP中: private void send_password_chk(){ string response = Sendpw ("http://localhost/quiz/passwordchk.php?idid="+Gameid+"&pass="+Gamepw); } private string Sendpw(string url) { try {
private void send_password_chk(){
string response = Sendpw ("http://localhost/quiz/passwordchk.php?idid="+Gameid+"&pass="+Gamepw);
}
private string Sendpw(string url)
{
try
{
using (WebClient client = new WebClient())
{
return client.DownloadString(new Uri(url));
}
}
catch(WebException ex) {
return null;
}
}
我执行PHP代码,得到以下结果:
注意:未定义索引:第8行的/Applications/XAMPP/xamppfiles/htdocs/quick/passwordchk.php中的idid
注意:未定义索引:第9行的pass-in/Applications/XAMPP/xamppfiles/htdocs/quick/passwordchk.php
但是插入查询是可以的。数据库中有数据
问题是什么?SQL注入警报。在构建SQL查询时不要使用字符串连接。显而易见的答案是,您没有将idid+pass发送到php代码中。。。正如它明确指出的那样,$_GET[“idid”]并不存在。
$id_val = $_GET["idid"];
$pw_val = $_GET["pass"];
$sql = "INSERT INTO member (gameid, gamepw, nickname, birth, gender) VALUES ('".$id_val."',password('".$pw_val."'),'");