<%@LANGUAGE="VBSCRIPT"%> 
<!--#include file="conn.asp" -->
<!--#include file="function.asp" -->
<%
' *** Edit Operations: declare variables

MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) <> "") Then

  MM_editConnection = MM_wish_STRING
  MM_editTable = "wish"
  MM_editRedirectUrl = "index.asp"
  MM_fieldsStr  = "wish_poster|value|wish_postersex|value|wish_postercity|value|wish_posterqq|value|wish_posteremail|value|wish_posterhome|value|wish_type|value|wish_content|value|wish_count|value"
  MM_columnsStr = "wish_poster|',none,''|wish_postersex|none,none,NULL|wish_postercity|',none,''|wish_posterqq|',none,''|wish_posteremail|',none,''|wish_posterhome|',none,''|wish_type|',none,''|wish_content|',none,''|wish_count|none,none,NULL"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
  
  ' set the form values
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(i+1) =ReplaceBadChar(CStr(Request.Form(MM_fields(i))))
	if MM_fields(i+1) <> "" then
	MM_fields(i+1) = left(MM_fields(i+1),300)
	end if
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

If (CStr(Request("MM_insert")) <> "") Then

  ' create the sql insert statement
  MM_tableValues = ""
  MM_dbValues = ""
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    FormVal = MM_fields(i+1)
    MM_typeArray = Split(MM_columns(i+1),",")
    Delim = MM_typeArray(0)
    If (Delim = "none") Then Delim = ""
    AltVal = MM_typeArray(1)
    If (AltVal = "none") Then AltVal = ""
    EmptyVal = MM_typeArray(2)
    If (EmptyVal = "none") Then EmptyVal = ""
    If (FormVal = "") Then
      FormVal = EmptyVal
    Else
      If (AltVal <> "") Then
        FormVal = AltVal
      ElseIf (Delim = "'") Then  ' escape quotes
        FormVal = "'" & Replace(FormVal,"'","''") & "'"
      Else
        FormVal = Delim + FormVal + Delim
      End If
    End If
    If (i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End if
    MM_tableValues = MM_tableValues & MM_columns(i)
    MM_dbValues = MM_dbValues & FormVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

  If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>
<html>
<head>
<title>我要祈愿</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<SCRIPT language=javascript src="navigation.js" type=text/javascript></SCRIPT>
<script language="JavaScript">
<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('★算命网★错误小提示:\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}
//-->
</script>
<style type="text/css">
<!--
BODY{
	scrollbar-face-color: #d4d0c8;
	scrollbar-highlight-color:#D4D0C8;
	scrollbar-shadow-color:#d6d6d6;
	scrollbar-3dlight-color:#e6e6e6;
	scrollbar-arrow-color:#006699;
	scrollbar-track-color:#dfdfdf;
	scrollbar-darkshadow-color: #808080;
	background-color: #EFF8FE;
}
#tipBox {
width: 160;BACKGROUND: #ffffff; BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; BORDER-RIGHT: black 1pt solid; BORDER-TOP: black 1pt solid; FONT-FAMILY: 宋体; FONT-SIZE: 9pt; POSITION: absolute; VISIBILITY: hidden; padding:2 ;Z-INDEX: 100
}
A:link {font-family:"Verdana",  "宋体"; COLOR: #000000;  font-size: 12px;  TEXT-DECORATION: none }
A:visited {font-family: "Verdana", "宋体";	COLOR: #000000; FONT-SIZE:12px; TEXT-DECORATION: none }
A:active {font-family: "Verdana", "宋体"; COLOR: #000099; FONT-SIZE: 12px; TEXT-DECORATION: none }
A:hover {font-family: "Verdana", "宋体"; COLOR: #dd0000; FONT-SIZE: 12px; TEXT-DECORATION: underline }
.smallTxt{FONT-SIZE: 12px; FONT-FAMILY: "Tahoma","Arial","sans-serif"}
.style3 {FONT-SIZE: 14px; FONT-FAMILY: "Tahoma","Arial","sans-serif"; }
-->
</style>
</head>
<body leftmargin="0" topmargin="0">
<table width="742" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr> 
    <td width="742" align="center" valign="top"  background="images/bg.gif"> 
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="47%" height="50"></td>
          <td width="53%" height="50"><a href="write.asp"><img src="images/wyqy.gif" border="0"></a></td>
        </tr>
		  <tr> 
          <td colspan="2" height="60"></td>
        </tr>
      </table>
      <table width="675" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="675" align="center"> 
            <table width="675" border="0" cellspacing="0" cellpadding="0">
             <tr align="center" valign="top"> 
                <td valign="middle">
				<table width="90%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#DFDFDF" class="smallTxt">
        <form name="form1" method="POST" action="<%=MM_editAction%>">
          <tr bgcolor="#FF9933"> 
            <td align="center" height="25"><a href="index.asp"><span class="style3"><font color="#ffffff">祈愿板</font></span></a></td>
            <td align="center" height="25"><span class="style3">合十，开始祈愿</span></td>
          </tr>
          <tr> 
            <td bgcolor="#F7F3F7" width="24%" height="23">我的名字-</td>
            <td bgcolor="#F7F3F7" width="76%"> 
              <input type="text" name="wish_poster" size="30" maxlength="20">
              <font color="#FF9A31"> * </font></td>
          </tr>
          <tr> 
            <td bgcolor="#F7F3F7" width="24%" height="23">我的性别-</td>
            <td bgcolor="#F7F3F7" width="76%"> 
              <input type="radio" name="wish_postersex" value="0" checked>
              帅哥 
              <input type="radio" name="wish_postersex" value="1">
              美女 <font color="#FF9A31">*</font></td>
          </tr>
          <tr> 
            <td bgcolor="#F7F3F7" width="24%" height="23">来自-</td>
            <td bgcolor="#F7F3F7" width="76%"> 
              <input type="text" name="wish_postercity" size="30" maxlength="30">
              <font color="#FF9A31"> * </font></td>
          </tr>
          <tr> 
            <td bgcolor="#F7F3F7" width="24%" height="23">我的<span class="fonten">QQ-</span></td>
            <td bgcolor="#F7F3F7" width="76%"> 
              <input type="text" name="wish_posterqq" size="20" maxlength="15">
            </td>
          </tr>
          <tr> 
            <td bgcolor="#F7F3F7" width="24%" class="fonten" height="23">E-Mail-</td>
            <td bgcolor="#F7F3F7" width="76%"> 
              <input type="text" name="wish_posteremail" size="30" maxlength="20">
            </td>
          </tr>
          <tr> 
            <td bgcolor="#F7F3F7" width="24%" height="23">主页地址-</td>
            <td bgcolor="#F7F3F7" width="76%"> 
              <input type="text" name="wish_posterhome" size="40" maxlength="30">
            </td>
          </tr>
          <tr> 
            <td bgcolor="#F7F3F7" width="24%" height="23">祈愿类型-</td>
            <td bgcolor="#F7F3F7" width="76%"> 
              <select name="wish_type" class="textfield">
                <option value="future">将来</option>
                <option value="family">家庭</option>
                <option value="health">健康</option>
                <option value="life">生活</option>
                <option value="love">恋爱</option>
                <option value="study">学业</option>
              </select>
              <font color="#FF9A31"> *</font> </td>
          </tr>
          <tr> 
            <td bgcolor="#F7F3F7" width="24%" height="23" valign="top">最真诚的话语-</td>
            <td bgcolor="#F7F3F7" width="76%"> 
              <textarea class="textfield" name="wish_content" cols="45" rows="6"></textarea>
              <font color="#FF9A31">* </font></td>
          </tr>
          <tr align="center"> 
            <td bgcolor="#F7F3F7" colspan="2" height="25"> 
              <input type="submit" name="Submit" value="送出祈愿" onClick="YY_checkform('form1','wish_postersex[0]','#q','2','帅哥or美女？','wish_postersex[1]','#q','2','帅哥or美女？','wish_poster','#q','0','佛祖还不知道你的名字呢？','wish_postercity','#q','0','西西，你从何处来？','wish_posterqq','1000_999999999999999','1','请输入正确的QQ号码！','wish_posteremail','S','2','E-mail好象有点错误哎！','wish_content','1','1','你许的愿呢？？？');return document.MM_returnValue"  style='cursor:hand;COLOR: #ff0000;'>
              <input type="reset" name="reset" value="重写祈愿">
              <input type="hidden" name="wish_count" value="0">
            </td>
          </tr>
          <input type="hidden" name="MM_insert" value="true">
        </form>
      </table>
				</td>
 </tr>
            </table>
</td>
</tr>
    </table>
	</td>
  </tr>
  <tr> 
  <td align="center" height="50"><span class="smallTxt"><font color="#FF0000">真诚祈愿板</font> v1.0 beta by<font color="#CC6600"> 便民网-www.99fad.cn</font></span></td>
  </tr>	
  <tr> 
    <td width="100%" bgcolor="#EEEEEE" align="right"><!--#include file="copyright.asp" --></td>
  </tr>
</table>
</body>
</html>