¾È³çÇϼ¼¿ä. ÇØÇÇCGI À¥¸¶½ºÅÍ À±¿µ¿õÀÔ´Ï´Ù. 1³âÀ» ¹Ì·ç´ø Â÷¿¡ °Á¸¦ ½ÃÀÛÇϳ׿ä. (1³â¸¸¿¡ ½Ã°£ÀÌ Á» ³ª¼ -_-v ÄÐ~)
¿¹Àü DBI¿Í ÆÞÀÇ °ü°è¿¡ ´ëÇؼ ¼³¸íÀ» µå·È½À´Ï´Ù. ÀÌÁ¦´Â ¾à°£ ½ÇÀü ¹®Á¦ÀÎ DBI¿Í ÆÞÀÇ ¿¬°á ±×¸®°í °£´ÜÇÑ ¿¹Á¦¸¦ º¾´Ï´Ù. À̹ø °Á´ perl¿¡¼ mysql ¾ÈÀ¸·Î ¾î¶»°Ô °ªÀ» ³Ö´ÂÁö ¾Ë¾Æº¾´Ï´Ù.
¿ì¼± ¾ÕÀ¸·Î °Á¿¡ ¾µ Å×À̺íÀ» ¸¸µé¾îº¸°Ú½À´Ï´Ù. ¾Æ·¡¸¦ Âü°íÇϼż mysql¿¡ ÀÚ½ÅÀÌ »ç¿ëÇÏ´Â DB³»¿¡ ¾Æ·¡ Å×À̺íÀ» ¸¸µì´Ï´Ù. (Áߺ¹ÀÌ µÇÁö ¾Ê°Ô Á¶±Ý µ¶Æ¯ÇÑ Çʵå À̸§À» »ç¿ëÇßÁÒ ^^)
CREATE TABLE happy_hero_okok ( number int(11) DEFAULT '0' NOT NULL auto_increment, name varchar(100) NOT NULL, email varchar(100), title varchar(200) NOT NULL, comment text NOT NULL, inquire int(10) DEFAULT '0' NOT NULL, date date DEFAULT '0000-00-00' NOT NULL, PRIMARY KEY (number) );
¹æ¸í·ÏÀ» ¿ì¼± ¸¸µé¾î º¼ »ý°¢ÀÌ´Ï±î ¹æ¸í·Ï¿¡ ¸Â°Ô ÃÖ¼ÒÇÑ °£´ÜÈ÷ Å×À̺íÀ» ¸¸µé¾î º¸¾Ò½À´Ï´Ù. number´Â ÇÁ¶óÀ̸Ӹ®Å°ÀÌ°í ÀÚµ¿Áõ°¡ name À̸§ ÀÔ·ÂÇÒ°÷ email À̸ÞÀÏ ÀÔ·ÂÇÒ°÷ title ¹æ¸í·Ï Á¦¸ñ ÀÔ·ÂÇÒ°÷ comment ¹æ¸í·Ï ³»¿ëÀÔ·ÂÇÒ°÷ inquire Á¶È¸¼ö¸¦ ³ªÅ¸³¾°÷ date ±Û µî·ÏÀÏ ÀúÀåÇÒ°÷. ÀÌ»óÀÔ´Ï´Ù.
http://www.happycgi.com/lecture/1127test.cgi À§ ÁÖ¼Ò´Â Å×½ºÆ®ÁÖ¼ÒÀÔ´Ï´Ù.
¾Æ·¡´Â ¼Ò½ºÄÚµåÀÌ°í ¾ÐÃàÆÄÀϷεµ ¹ÞÀ»¼ö ÀÖ½À´Ï´Ù.
#!/usr/bin/perl ######################################################### use DBI; #DBI¶õ ¸ðµâÀ» »ç¿ëÇÑ´Ù°í ¼±¾ðÇÕ´Ï´Ù. $database = "yourDBname"; #ÀÚ½ÅÀÇ DB¸í $hostname = "localhost"; #mysql È£½ºÆ® À§Ä¡ $dsn = "DBI:mysql:database=$database;host=$hostname"; $user = "mysqlid"; #mysql ¾ÆÀ̵ð $pw = "mysqlpass"; #mysql Æнº¿öµå $dbh = DBI->connect("$dsn", "$user", "$pw"); $table_name = "happy_hero_okok"; #»ç¿ëÇÒ Å×À̺í¸í ######################################################### # Àӽ÷Π°ªÀ» ÀÏ´Ü ÁÝ´Ï´Ù. # ¿À´ÃÀº ÀԷ¸¸ Å×½ºÆ®Çϱ¸¿ä. #
$name = "Å×½ºÆ®Áß"; $email = 'webmaster@happycgi.com'; $title = "Å×½ºÆ®Á¦¸ñ"; $comment = "³»¿ëÀÔ´Ï´Ù.\n Àߵdzª¿ä?"; $inquire = "0";
print "content-type:text/html\n\n"; # ¾Æ·¡ ±¸¹®Àº °¡Àå ¸¹ÀÌ ¾²´Â ±¸¹®ÀÔ´Ï´Ù. # do¸¦ Àß ¾È¾²½Ã´Â ºÐµµ ÀÖ´Ù´øµ¥ # Á¦°¡ º¸±â¿£ Á¦ÀÏ ÆíÇÑ°Í °°¾Æ¼ ¸»ÀÌÁÒ. ^^ # Åë°·Î ±×³É ¿Ü¿ì¼¼¿ä.
$sth = $dbh->do ("insert into $table_name values('','$name','$email','$title','$comment','$inquire',curdate()) ") or die print "$DBI::errstr DB Á¢¼Ó¿¡·¯";
# $DBI::errstrt ÀÌ ¹«¾ùÀ̳ĸé # dbh¿¡¼ ´øÁ®ÁØ ¸í·É¿¡ ¹®Á¦°¡ ÀÖÀ»¶§ ±× ¹®Á¦Á¡À» Ãâ·ÂÇØÁÝ´Ï´Ù. # or die ¹®Àº ¾Æ½ÃÁÒ. ¾ÈµÇ¸é ½ºÅéÇضó..
print "Àß µî·ÏµÇ¾ú³×¿ä. ^^";
# µî·ÏÀÌ Àß µÇ¾úÀ¸¸é print ¹®À¸·Î °¡¼ Àß µî·ÏµÇ¾ú´Ù°í Ãâ·ÂÇÏ°ÚÁÒ?
¿À´ÃÀº ¿ä±îÁö ÀÔ´Ï´Ù. ¾ÆÁÖ °£´ÜÇÑ ¼Ò½ºÁÒ? À¥»ó¿¡ È£ÃâÀ» ÇÏ¸é ¹«Á¶°Ç DB°¡ ÀúÀåµË´Ï´Ù. (´ç¿¬ÇÏÁö¸¸ ... -_-;;;) ÀúÀåµÇ¾ú³ª mysql¿¡¼ Á÷Á¢ È®ÀÎÀ» Çغ¸±¸¿ä.
ƯÈ÷ ¾Æ·¡ ¹®Àå
#!/usr/bin/perl ######################################################### use DBI; #DBI¶õ ¸ðµâÀ» »ç¿ëÇÑ´Ù°í ¼±¾ðÇÕ´Ï´Ù. $database = "yourDBname"; #ÀÚ½ÅÀÇ DB¸í $hostname = "localhost"; #mysql È£½ºÆ® À§Ä¡ $dsn = "DBI:mysql:database=$database;host=$hostname"; $user = "mysqlid"; #mysql ¾ÆÀ̵ð $pw = "mysqlpass"; #mysql Æнº¿öµå $dbh = DBI->connect("$dsn", "$user", "$pw"); $table_name = "happy_hero_okok"; #»ç¿ëÇÒ Å×À̺í¸í #########################################################
Àº ¸Å¹ø ¾²ÀÏ°ÍÀÌ´Ï ÀÚÁÖ º¹»çÇؼ ¾µ°Ì´Ï´Ù. ¾Ï±â Çϼ¼¿ä. (Àú´Â ±×³É °è¼Ó º¹»çÇؼ ¾¹´Ï´Ù. ¿ì° ¿Ü¿ö...-_-;;;)
´ÙÀ½ °Á´ ÀÔ·ÂµÈ Á¤º¸¸¦ ºÒ·¯¿À´Â ºÎºÐÀ» ÇÏ°Ú½À´Ï´Ù. ÀÌÁ¦ ¹æ¸í·Ï ÀÛ¾÷ ½ÃÀÛÀÌ µÇ¾ú³×¿ä. ^^
Áñ perl Çϼ¼¿ä. ÁÁÀº ÇÏ·çµÇ½Ã±¸¿ä.
Ã߽Š: ÆíÁý±â´Â ¾Æ·¡²¨¸¦ ½áº¸¼¼¿ä. http://www.happycgi.com/detail.cgi?number=4374&p=1
|