Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¼ÌÐøÕª³­£º½ÌÄãÓÃPHPдMySQLÊý¾Ý¿âµÄÓû§ÈÏ֤ϵͳ

Óû§ÈÏÖ¤µÄÔ­ÀíºÜ¼òµ¥£ºÊ×ÏÈÐèÒªÓû§ÔÚÒ³ÃæÉÏÌîÈëÓû§ÃûºÍÃÜÂ룬µ±È»Ã»×¢²áµÄÓû§ÐèÒªÏÈ×¢²á¡£È»ºóµ÷ÓÃÊý¾Ý¿âËÑË÷ÊÇ·ñÓÐÏàÓ¦µÄÓû§¡£Èç¹ûÓоÍÈ·ÈÏ£¬Ã»ÓÐÔòÌáÐÑÓû§ÏÈ×¢²á¡£Ê¹ÓÃPHPÀ´Íê³ÉÕâÒ»Çкܼòµ¥£¬µ«ÐèҪעÒâµÄÊÇÈç¹ûÏëÔÚÒÔºóµÄÒ³ÃæÖж¼ÄÜÈ·ÈÏÓû§Éí·Ý¡£
µÚÒ»²½ÊÇ×öÒ»¸öµÇ¼µÄÒ³Ãæ¡£
µÚ¶þ²½¿ªÊ¼µÇ¼ºóµÄÈ·ÈϳÌÐòµÄÉè¼Æ¡£
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
login.php:¡¡
mysql_connect("localhost","user","password")
/*Á¬½ÓÊý¾Ý¿â£¬Óû§ÃûºÍÃÜÂë×ÔÐÐÐÞ¸Ä*/
or die("ÎÞ·¨Á¬½ÓÊý¾Ý¿â£¬ÇëÖØÊÔ");
mysql_select_db("userinfo")
or die("ÎÞ·¨Ñ¡ÔñÊý¾Ý¿â£¬ÇëÖØÊÔ");
$today=date("Y-m-d H:i:s");
$query="
select id
from usertbl
where name=$name and password=$password
/*´ÓÊý¾Ý¿âÖÐËÑË÷ºÍµÇ¼Óû§ÏàÓ¦µÄ×ÊÁÏ*/
";
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
if($numrows==0){
/*ÑéÖ¤ÊÇ·ñÄÜÕÒ³öÏàͬ×ÊÁϵÄÓû§£¬²»ÄÜÔòδע²á*/
echo ·Ç·¨Óû§
;
echo Çë×¢²áÏÈ
;
echo ÖØÊÔ
;
}
else{
$row=mysql_fetch_array($result);
$id=$row[0];
$query="
update usertbl
set lastlogin=$today
where id=$id";
$result=mysql_query($query);
SetCookie("usercookie", "»¶Ó­Äã,$name");
¡¡/*ÕâÀïʹÓÃÁËcookie£¬ÒÔ·½±ãÖ®ºóµÄÒ³ÃæÈÏÖ¤¡£
µ«ÎÒ먦·¢ÍêÕâÒ»¿é¡£Ï£ÍûÓÐÐËȤµÄÅóÓÑÖ¸Õý*/
echo µÇ¼³É¹¦
;
echo Çë½ø£¡
;
}
?>
µÚÈý²½×öºÃ×¢²áµÄÒ³Ãæ¡£
µÚËIJ½ÊÇ×¢²áºóµÄÉí·ÝÈ·ÈϺÍÊäÈëÊý¾Ý¿â¡£
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
register.php:
mysql_connect("localhost","user","password")
/*ÇëÐÞ¸ÄÓû§ÃûºÍÃÜÂë*/
or die("ÎÞ·¨Á¬½ÓÊý¾Ý¿â£¬ÇëÖØÊÔ");
mysql_select_db("userinfo")
or die("ÎÞ·¨Ñ¡ÔñÊý¾Ý¿â£¬ÇëÖØÊÔ");
$query="select id from usertbl where name=$name\";
¡¡/*´ÓÊý¾Ý¿âÖÐËÑË÷ÏàͬÃû×ÖµÄÓû§×ÊÁÏ*/
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
if($numrows!=0) /*ÕÒµ½Á˵±È»¾ÍÊÇÓÐÈËÏÈ×¢²áÁËÏàͬµÄÃû×Ö*/
{echo ÒÑÓÐÈË×¢²á´ËÃû£¬ÇëÖØÐÂÑ¡ÔñÃû×Ö!;}
else
{$query="insert into usertbl values(0,$name,$password,\)";
¡¡/*ÕÒ²»µ½ÏàͬµÄ¾ÍÊäÈëеÄÓû§×ÊÁÏ*/
mysql_query($query);
echo ×¢²á³É¹¦;
echo ÇëµÇ¼!;}
?>
ÏÂÒ»²½ÊÇcookieµÄʹÓã¬ÎÒÔ­´òËãʹÓÃcookieÀ´Ê¹Ã¿Ò»Ò³¶¼ÄÜʶ±ðÓû§Éí·Ý£¬µ«ÓÉÓÚ±ðµÄÒ³


Ïà¹ØÎĵµ£º

³õѧPHPµÄ18¸ö»ù´¡Àý³Ì

 
ÈçºÎ´´½¨ÎÒÃǵĵÚÒ»¸öPHPÒ³ÃæÄØ£¿·Ç³£¼òµ¥µÄ£¡Ñ¡ÔñÎÒÃÇʹÓõÄÒ»¸ö×îºÃµÄÉè¼Æ¹¤¾ß£¬µ±È»ÄãÒ²¿ÉÒÔ Ö»Ê¹ÓüÇʱ¾¡£´´½¨Ö®ºó¼ÇµÃÒª±£´æΪÀ©Õ¹ÃûΪPHPµÄÎļþ£¬È»ºó´«µ½ÎÒÃǵķþÎñÆ÷
ÉÏ¡£
¡¡¡¡ÔÚ±àдPHP³ÌÐò֮ǰͨ³£ÎÒÃÇÐèÒªÅäÖÃÎÒÃǵĻ·¾³£¬Ò²¾ÍÊÇ˵·þÎñÆ÷
ÒªÖ§³ÖPHP²ÅÄÜÐа¡
¡¡¡¡Ò»¡¢PHPµÄ»ù±¾½á¹¹£º
¡¡¡¡Ê¹ÓÃIncl ......

Ô¶³ÌÁ¬½Ómysql

½â¾ö·½·¨(ת)£º---µ«Ö´ÐеÚÒ»Öְ취ʱ³öÏÖ´íÎ󣬵ڶþÖÖ°ì·¨³É¹¦
1¡£¸Ä±í·¨¡£¿ÉÄÜÊÇÄãµÄÕʺŲ»ÔÊÐí´ÓÔ¶³ÌµÇ½£¬Ö»ÄÜÔÚlocalhost¡£Õâ¸öʱºòÖ»ÒªÔÚlocalhostµÄÄÇ̨µçÄÔ£¬µÇÈëmysqlºó£¬¸ü¸Ä "mysql" Êý¾Ý¿âÀïµÄ "user" ±íÀïµÄ "host" Ï´Ó"localhost"¸Ä³Æ"%"
mysql -u root -pvmwaremysql>use mysql;mysql>update use ......

phpµÄ½Å±¾ÀïÖ±½Ó½¨Á¢mysqlÀïµÄÊý¾Ý¿â

 ÎÊ£º
±ÈÈçÎÒÏëÖ±½ÓÔÚphp µÄ½Å±¾Àïдһ¸öÀàËÆ£¬install.phpµÄ½Å±¾
Õâ¸ö½Å±¾µÄ×÷ÓþÍÊÇ£¬Á¬½ÓmysqlÊý¾Ý¿â£¬²¢½¨Á¢ÎÒËùÏëÒª½¨Á¢µÄÊý¾Ý¿â£¬Êý¾Ý±í£¬ÒÔ¼°Ïà¹Ø×ֶΡ£
Çë¾ßÌåдһ¸öÀý×Ó£¬Ð»Ð»£¡
______________________________________________________________________________________________
´ð1£º
連½Ó·½· ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ