$host="localhost"; // Host name$username="emmuser"; // Mysql username$password="emmpass"; // Mysql password$db_name="emmuser"; // Database name$tbl_name="userID"; // Table name// Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB");// To protect MySQL injection (more detail about MySQL injection)$myusername = $login_username;$mypassword = $secretkey;$myusername = stripslashes($myusername);$mypassword = stripslashes($mypassword);$myusername = mysql_real_escape_string($myusername);$mypassword = mysql_real_escape_string($mypassword);$sql="SELECT IDnumber FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";$result=mysql_query($sql);// Mysql_num_row is counting table row$count=mysql_num_rows($result);// If result matched $myusername and $mypassword, table row must be 1 rowif($count==1){// Register $myusername, $mypassword and redirect to file "login_success.php"$row = mysql_fetch_array($result)$login_username= $row['username'];}
2010年6月2日 星期三
[PHP] php連mySQL 資料庫
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言