|  | 
	                
  
    | 
	 
        ผมระบบสมาชิกครับ แต่ว่าพอใส่รหัสผ่านและชื่อถูกแต่มนันไม่ยอม เข้าเงือนไขแรกอ่ะครับ     |  
    |  |  
 
              
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | รบกวนผู้รู้ทุกท่านด้วยน๊ะครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-04-27 22:17:46 | By :
                            หัดเขียน |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | เขียนธรรมดาก็ได้นะ เล่น function 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-04-28 11:51:30 | By :
                            บอม |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 <?php
	
    function process($user,$pass){
    $host = "localhost";
    $user = "root";
    $pw = "1234";
    $dbname = "register";
    mysql_connect($host,$user,$pw) or die ("ติดต่อ Host ไม่ได้");
	mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
	$sql="select * from regis where id='$user' and pw='$pass'";            
	$query=mysql_query($sql) or die(mysql_error()."\n".$sql);                 
	$num=mysql_num_rows($query);                     
	//mysql_close(); อย่าพึ่งปิดการเชื่อมต่อ
	//$dbquery = mysql_db_query($dbname,$sql);
	//$num_rows = mysql_num_rows($dbquery);
	echo"$num";
	if($num==1){
		return true ;
	}
	else{
		return false;
	}
}
mysql_close(); //ย้ายมาใส่ที่นี่แทน 
?>
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-04-28 12:11:52 | By :
                            Manussawin |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 <?php
	
    function process($user,$pass){
    $host = "localhost";
    $user = "root";
    $pw = "1234";
    $dbname = "register";
    mysql_connect($host,$user,$pw) or die ("ติดต่อ Host ไม่ได้");
	mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
	$sql="select * from regis where id='$user' and pw='$pass'";            
	$query=mysql_query($sql) or die(mysql_error()."\n".$sql);                 
	$num=mysql_num_rows($query);                     
	mysql_close();
	//$dbquery = mysql_db_query($dbname,$sql);
	//$num_rows = mysql_num_rows($dbquery);
	echo"$num";
	if($num==1){
		return true ;
	}
	else{
		return false;
	}
}
?>
 จาก Code จะเห็นได้ว่า $user มันซ้ำๆ นะ ถึงคุณจะกรอก user อะไรก็ตาม มันก็จะแทนด้วย root เสมอ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-04-28 13:01:44 | By :
                            onedan |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 <?php
	
    function process($user,$pass){ // รับค่า user password
    $host = "localhost";
    $user = "root"; // เปลียนค่า user ** ตัวแปรซ้ำนะ
    $pw = "1234";
    $dbname = "register";
    mysql_connect($host,$user,$pw) or die ("ติดต่อ Host ไม่ได้");
	mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
	$sql="select * from regis where id='$user' and pw='$pass'";    // ดึงข้อมูล ** แล้วจะเจอหรอในเมื่อเปลียนค่าใน $user แล้ว      
	$query=mysql_query($sql) or die(mysql_error()."\n".$sql);                 
	$num=mysql_num_rows($query);                     
	mysql_close();
	//$dbquery = mysql_db_query($dbname,$sql);
	//$num_rows = mysql_num_rows($dbquery);
	echo"$num";
	if($num==1){
		return true ;
	}
	else{
		return false;
	}
}
?>
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-04-28 13:04:53 | By :
                            onedan |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | เอาแบบนี้ไปละกัน 
 Code (PHP)
 
 <?php
	
    function process($user2,$pass2){
    $host = "localhost";
    $user = "root";
    $pw = "1234";
    $dbname = "register";
    mysql_connect($host,$user,$pw) or die ("ติดต่อ Host ไม่ได้");
	mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
	$sql="select * from regis where id='$user2' and pw='$pass2'";            
	$query=mysql_query($sql) or die(mysql_error()."\n".$sql);                 
	$num=mysql_num_rows($query);                     
	//$dbquery = mysql_db_query($dbname,$sql);
	//$num_rows = mysql_num_rows($dbquery);
	echo"$num";
	if($num>0){
		return true ;
	}
	else{
		return false;
	}
}
?>
mysql_close();
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-04-28 13:20:15 | By :
                            onedan |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 <?php
	
    function process($user2,$pass2){
    $host = "localhost";
    $user = "root";
    $pw = "1234";
    $dbname = "register";
    mysql_connect($host,$user,$pw) or die ("ติดต่อ Host ไม่ได้");
	mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
	$sql="select * from regis where id='$user2' and pw='$pass2'";            
	$query=mysql_query($sql) or die(mysql_error()."\n".$sql);                 
	$num=mysql_num_rows($query);                     
	//$dbquery = mysql_db_query($dbname,$sql);
	//$num_rows = mysql_num_rows($dbquery);
	echo"$num";
	if($num>0){
		return true ;
	}
	else{
		return false;
	}
}
mysql_close();
?>
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-04-28 22:12:31 | By :
                            Manussawin |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | จริงด้วยครับ ขอบคุณมากกกกกกกกกกกกกกกก ครับบบบบบบบบบบบบบบบบบบบบบบ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2010-04-28 23:10:49 | By :
                            หัดเขียน |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |