2013-02-21 213 views
0

我需要小的幫助,因爲即時通訊卡和IM不是PHP和vB.net連接好...... 所以這裏的問題是,我管理可以連接到數據庫,並PHP腳本顯示我是否即時連接或不,如果用戶/ PW是正確的抓住一切正常,但現在我不知道如何抓住,在新的形式顯示,該用戶的數據,並顯示在標籤中,如在數據庫它有註冊日期,最後一次登錄和電子郵件,我想他們我的第二個形式..所以,如果有人可以幫助我那些東西分類和管理來完成目標,我會很心存感激!抓住MySQL的信息在PHP與vb.net

Usercheck.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 

回答

0

嘗試宣告值在vb.net一個全局變量。然後,您可以在整個項目中訪問所有變量,甚至以其他形式訪問。