묻고답하기

폼에일에서염 ....  이거 같은 경우에는 각각의 폼에 아무런 텍스트도 들어가지 않은 상태에서

메일보내기를 하면 작성 내용 중 빠트린 것이 있다는 경고가 나옵니다 ...

그런데 이것을 .......

약간 수정하여 ...  받는사람 메일 주소나 보내는 사람 메일 주소가 이메일 주소 형식에

어긋났을때에 이메일 주소를 다시 쓰라는 경고문이나 경고 페이지로 이동하게 할려면

이 소스를 어떻게 수정해야 할까요 ??

고수님들께 부탁드립니다 ...........

폼메일 주소 : http://www.yagobo.com/cgi-bin/spmail/spmail_km.cgi

================================spmail_km.cgi 소스 시작 ==================

#!/usr/bin/perl

&perse;
#------------------- 수정해야 할 부분 -----------------------------
$cgi_url="http://www.yagobo.com/cgi-bin/spmail/spmail_km.cgi";                       # spmail.cgi파일이 있는곳의 URL
$img_url="http://www.yagobo.com/cgi-bin/spmail";                                       # 이미지 URL
$mail_prog='/usr/sbin/sendmail';     # 서버에서 sendmail프로그램 절대경로
$homeframe="http://cafe.daum.net/kmcasting";   # 편지보낸후 [홈으로]를 클릭 했을때 가는 프레임!
$home_url="http://cafe.daum.net/kmcasting";                         # 보낸 메일에 표시될 자신의 홈페이지 주소
$to_mail='yagobo1@hanmail.net';                       # 받는사람 email에 기본으로 표시될 메일(안적어두 됨-.-)
$color1="#FFB524";             #메일 테이블의 진한색(이색도 이뻐요->#64AC4C)
$color2="#FFF3E9";             #메일 테이블의 연한색(이색도 이뻐요->#EFFFE8)
#---------------------------------------------------------------
# 인터피아 사용자는 homeframe과 home_url 그리고 to_mail만 수정해서 쓰시면 됩니당.*^^*

$ip = $ENV{'REMOTE_ADDR'};

if(!$FORM{'gotomail'}){
        &write_form;
}

&error;
&get_time;
&send_mail;
&ending_form;

sub perse{
        if($ENV{'REQUEST_METHOD'} eq "GET") {
                $buffer = $ENV{'QUERY_STRING'};
    }
        else {
        read( STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    }

    @pairs = split(/&/,$buffer);
    foreach $pair( @pairs ) {
        ($name,$value)=split(/=/,$pair);
                $value =~ tr/+/ /;
                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
                $FORM{$name} = $value;
    }
}

sub head {
                print "Content-type: text/htmlnn";
                print "<html>n";
                print "<head>n";
                print "<title>= Form Mail =</title>n";
                print "<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">n";
                print "<style type='text/css'>n";
                print "<!--n";
                print "A:link {font:9pt 굴림;color:black;text-decoration:none;}n";
                print "A:visited {font:9pt 굴림;color:black;text-decoration:none;}n";
                print "A:active {font:9pt 굴림;color:red;text-decoration:underline;}n";
                print "A:hover {color:blue;text-decoration:underline;}n";
                print ".main {color:$head_color;font-family:Verdana,Arial,굴림;font-size:10pt}n";
                print "p,br,body,td,select,input,form,textarea,option {font-size:10pt;}n";
                print ".ad{border:1 solid black}n";
                print ".cont{line-height:140%}n";
                print ".t{line-height:140%}n";
                print "-->n";
                print "</style>n";
                print "<script language="JavaScript">n";
                print "        function newin(width,height,url,name) {n";
                print "        msgWindow=window.open(url,name,'statusbar=no,scrollbars=no,status=yes,resizable=yes,width='+width+',height='+height)n";
                print "        }n";
                print "</script>n";
print <<STARTTT;
<script language=javascript>
function clearField(field){ if (field.value == field.defaultValue) {  field.value = ''; } }
function checkField(field){ if (field.value == '') { field.value = field.defaultValue; } }
</script>
STARTTT
                print "</head>n";
                print "<body><center>n";
}

sub foot {
        print "</center></body></html>n";
        exit;
}

sub error{
        if($FORM{'ment'} eq "" || $FORM{'tomail'} eq "" || $FORM{'myname'} eq "" || $FORM{'mymail'} eq "" || $FORM{'title'} eq "")
        {
                &head;
                print "<div align=left>n";
                print "<table border="0" cellspacing="0" width="500"><tr align="center"><td>n";
                print "<p> <p><br><br><br><br><br><br><br><font color=#200040>에러가 났습니다 ^.^;; 뭐 빠뜨린거 없나요?<p>모든 항목을 형식에 맞게 빼먹지 말고 적어 주세요! Please!</font><p>n";
                print "<A HREF="javascript:history.go(-1)" onfocus="this.blur()"><b><font color=#200040>◀◀ B A C K ▶▶</font></b></a>n";
             print "</td></tr></table></div>n";
                &foot;
        }
}

sub send_mail{
open (MAIL, "|$mail_prog -t") || die "화일 열기 실패!n";
           if ($FORM{'html'} ne "1") {
            $FORM{'ment'} =~ s/</</g;
        $FORM{'ment'} =~ s/>/>/g;
        $FORM{'ment'} =~ s/"/"/g;
        }
        $FORM{'ment'} =~ s/rn/<br>/g;
        print MAIL "To: $FORM{'+ '+ 'tomail'}n";
        print MAIL "From: $FORM{'myname'} <$FORM{'mymail'}>n";
        print MAIL "Subject:  $FORM{'title'}n";
    print MAIL "Content-type: text/htmlnn";
        print MAIL "<style type=text/css>n";
        print MAIL "a:link, a:visited, a:active { font-size:9pt; text-decoration:none; color:blue; }n";
        print MAIL "a:hover { font-size:9pt; text-decoration:underline; color:red; }n";
        print MAIL "body, td  { font-size:9pt }n";
        print MAIL ".main {font-size:10pt}n";
        print MAIL "</style>n";
        print MAIL "<table width=100% border=10 bordercolor=white cellpadding=0 cellspacing=0 bgcolor=white><tr><td align=center>n";
        print MAIL "<table width=440 cellpadding=1 cellspacing=0 bgcolor=$color1>n";
        print MAIL "<tr><td height=20 align=center><font face=굴림 class=main> $FORM{'title'} </font></td></tr>n";
        print MAIL "<tr><td>n";        
        print MAIL "<table width=100% cellpadding=3 cellspacing=0 bgcolor=#ffffff>n";
        print MAIL "<tr><td bgcolor=$color2><font face=굴림 class=main>n";
        print MAIL "보낸 날짜: $date $time<br>n";
        print MAIL "보낸 사람: $FORM{'myname'} (IP:$ip)<br>n";
    print MAIL "보낸 장소: <a href=$home_url target=_blank>$home_url</a>n";
        print MAIL "</font></td></tr>n";        
        print MAIL "<tr><td>n";                
        print MAIL "<font face=굴림 class=main>$FORM{'+ 'ment'}<br><br>n";                
    print MAIL "</font></td></tr>n";
        print MAIL "</table>n";
        print MAIL "</td></tr>n";        
        print MAIL "</table></td></tr></table>n";
        close (MAIL);
}
exit;

sub ending_form{
        &head;
        print "<br><br><br><br><br><br><br><br><br><br><div align="left"><table border="0" cellspacing="0" width="500"><tr align="center"><td><p><font color=#200040>Thank you!!!<br> <br> 편지가 배달 되었습니다.</font><br>n";
        print "<form><a href=$homeframe></a><a href=$cgi_url onfocus="this.blur()"><b>Back</b></a>n";
        print "</td></tr></table></div>n";
        &foot;
}

sub write_form{
        &head;
print <<END;
<form method="post" action="$cgi_url">
<input type="hidden" name="gotomail" value="1">
<input type="hidden" name="prog" value="$mail_prog">
<input type="hidden" name="home_url" value="$home_url">
<div align=left>
<br><br><br>
<table border="1" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 cellspacing=0 cellpadding=0 width="700">

<tr>
<td width="115" align=right>보내는 사람 이름  </td>
<td><p><input type="text" name="myname" value="" maxlength="10" size="40" onBlur="checkField(this)" onFocus="clearField(this)" style="background-color:white;border:1 solid gray"></td>
</tr>
<tr>
<td width="115" align=right>보내는 사람 메일  </td>
<td><p><input type="text" name="mymail" value="" maxlength="50" size="40" onBlur="checkField(this)" onFocus="clearField(this)" style="background-color:white;border:1 solid gray"></td>
</tr>
<tr>
</tr>
<tr>
<td width="115" align=right>받는 사람 메일  </td>
<td><p><input type="text" name="tomail" value="$to_mail" maxlength="50" size="40" onBlur="checkField(this)" onFocus="clearField(this)" style="background-color:white;border:1 solid gray"></td>
</tr>
<tr>
<td width="115" align=right>제목  </td>
<td>
<p><input type="text" name="title" value="" maxlength="20" size="70" onBlur="checkField(this)" onFocus="clearField(this)" style="background-color:white;border:1 solid gray"><input type=checkbox name=html value=1><font color=#200040>html</font>
</td>
</tr>
<td width="115" align=right>내용  </td>
<td>
<p><textarea name="ment" rows="25" cols="80" wrap="virtual" style="background-color:white;border:1 solid gray">
⊙ 이  름 :
⊙ 나  이 :
⊙ 성  별 :
⊙ 주  소 :
⊙ 학교/직장 :

⊙ 연락처/핸드폰 :
⊙ E-mail :

⊙ 키/몸무게 :
⊙ 특기 :
⊙ 경력사항 :
⊙ 희망분야 (가수,연기,댄스,VJ) :

⊙ 부모님 동의여부 (미성년자일 경우) :
   </textarea></td>
</tr><tr>
<td width="115" align=right>
<p><font size="2"> </font></td>
<td>
<p><input type="submit" value="Send" style="color:black;background-color:#F4F4F4;border:1 solid black;height:19px" onfocus="this.blur()"> <input type="reset" value="Reset" style="color:black;background-color:#F4F4F4;border:1 solid black;height:19px" onfocus="this.blur()"></td>
</tr>
</table>
</div>
</form>
</body>
</html>
END
        &foot;
}

sub get_time{
        ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
        if($year < 2000){
                if($year >= 100){
                        $year=($year-100)+2000;
                }
                else{
                        $year=2000+$year;
                }
        }
        $month = ($mon + 1);
if($hour > 12) {
                $hour = $hour - 12;
                $hour = "오후 $hour";
    }
    else{
                $hour = "오전 $hour";
    }

        $date = "$year년 $month월$mday일";
        $time = "$hour시$min분";
}


1;

===========================소스 끝 ===========================