我需要一点帮助,因为我卡住了,而且我对 php 和 vB.net 连接不太好......所以这是问题所在,我设法连接到 db 和 php 脚本显示我是否连接,如果用户获取/pw 是正确的,一切正常,但现在我不知道如何在显示新表单时获取该用户的数据并将其显示在标签中,就像在 db 中它有注册日期、上次登录和电子邮件一样,我想要让它们出现在我的第二个表格中。所以如果有人可以帮助我整理这些东西并设法完成目标,我将非常感激!
用户检查.php
<?php
if($_POST)
{
if(isset($_POST["username"]) && isset($_POST["password"]))
{
$connect = mysql_pconnect("localhost","username","password");
if($connect)
{
$select = mysql_select_db("mydatabase",$connect);
if($select)
{
$user = mysql_escape_string($_POST["username"]);
$pwd = mysql_escape_string($_POST["password"]);
$GetRows = mysql_query("SELECT * FROM MyTableHere WHERE username='$user' AND password='$pwd'");
$RowCount=mysql_num_rows($GetRows);
if($RowCount>0)
{
die("Correct !");
}
else
{
die("Incorrect !");
}
}
else
{
die("Unable to select database." . mysql_error());
}
}
else
{
die("Unable connect to database." . mysql_error());
}
}
else
{
die("Access Denied!");
}
}
else
{
die("Access Denied!");
}
?>
来自 Form1.vb 的片段
Function AuthUser(ByVal AuthenticationPage As String, ByVal Username As String, ByVal Password As String) As Boolean
Dim wc As New WebClient()
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Dim Data As String = String.Format("username={0}&password={1}", HttpUtility.UrlEncode(Username), HttpUtility.UrlEncode(Password))
Dim ResponseBytes() As Byte = wc.UploadData(AuthenticationPage, "POST", Encoding.ASCII.GetBytes(Data))
Dim Response As String = Encoding.ASCII.GetString(ResponseBytes)
If Response.Contains("Correct") Then
Return True
Else
Return False
End If
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If AuthUser("http://127.0.0.1/Usercheck.php", TextBox1.Text, TextBox2.Text) Then
Me.Hide()
Form2.Show()
Else
MsgBox("You have provided invalid username or password. Unable to login.")
End If
End Sub