如何添加成功保存到这些代码的通知

时间:2015-05-24 07:02:31

标签: asp-classic

我已经成功完成了添加数据的代码,但是当它成功保存数据时,没有任何通知我是否完成了。那么请你帮我添加一行说“你已经成功注册”,在它再次转回空白表格之前显示几秒钟。非常感谢你。

我的工作代码是..

<%
'Sample file Field-SaveAs.asp 
'Store extra upload info to a database
' and file contents to the disk
Server.ScriptTimeout = 5000

'Create upload form
'Using Huge-ASP file upload
'Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
'Using Pure-ASP file upload
Dim Form: Set Form = New ASPForm %><!--#INCLUDE FILE="_uploadz.asp"--><% 


Server.ScriptTimeout = 1000
Form.SizeLimit = &HA00000'10MB

'was the Form successfully received?
Const fsCompletted  = 0

If Form.State = fsCompletted Then 'Completted
  'Create destination path+filename for the source file.
  Dim DestinationPath, DestinationFileName, Pdfpath, pdffilename
  DestinationPath = Server.mapPath("UploadFolder")
  DestinationFileName = DestinationPath & "\" & Form("ref_img").FileName
  Pdfpath = Server.mapPath("PdfFolder")
  PdfFileName = Pdfpath & "\" & Form("refree_img").FileName  


  'Open recordset to store uploaded data
  Dim RS: Set RS = OpenUploadRS

  'Store extra info about upload to database
  RS.AddNew

   RS("showndate") = Now()
   RS("ref_name") = Form.Texts.Item("ref_name")  
   RS("ref_surname") = Form.Texts.Item("ref_surname")  
   RS("ref_add") = Form.Texts.Item("ref_add")  
   RS("ref_tel") = Form.Texts.Item("ref_tel")  
   RS("ref_img") = Form("ref_img").Filename   
   RS("refree_name") = Form.Texts.Item("refree_name")  
   RS("refree_surname") = Form.Texts.Item("refree_surname")  
   RS("refree_add") = Form.Texts.Item("refree_add")  
   RS("refree_tel") = Form.Texts.Item("refree_tel")     
   RS("refree_img") = Form("refree_img").Filename                       

  RS.Update

  Form("ref_img").SaveAs DestinationFileName
  Form("refree_img").SaveAs PdfFileName

ElseIf Form.State > 10 then
  Const fsSizeLimit = &HD
  Select case Form.State
        case fsSizeLimit: response.write  "<br><Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font><br>"
        case else response.write "<br><Font Color=red>Some form error.</Font><br>"
  end Select
End If'Form.State = 0 then

Function OpenUploadRS()
  Dim RS  : Set RS = CreateObject("ADODB.Recordset")

  'Open dynamic recordset, table Upload
  RS.Open "tbl_refer", GetConnection, 2, 2

  Set OpenUploadRS = RS
end Function 

Function GetConnection()
  dim Conn: Set Conn = CreateObject("ADODB.Connection")
  Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
    Conn.open "Data Source=" & Server.MapPath("../database/magi.mdb")    
    set GetConnection = Conn
end function



%>  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Magi Clean Wiper</TITLE>
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<script language="JavaScript" src='misc.js'></script>
<script language="JavaScript" src='calendar.js'></script>
<link rel="stylesheet" href="calendar.css" type="text/css">
<!--<meta http-equiv="Content-Type" content="text/html; charset=TIS-620">-->
<meta http-equiv="Content-Type" content="text/html; charset=TIS-620">
<!--<meta http-equiv="Content-Type" content="text/html; charset=windows-874">-->
</HEAD>

<body bgcolor="#ffffff"> 


                                        <!-- Card content -->
<!--<form method=post ENCTYPE="multipart/form-data">                         -->
<form name="myform" method="POST" ENCTYPE="multipart/form-data" OnSubmit="return ProgressBar();" Action="<%=PostURL%>">             
<table cellspacing="3" cellpadding="0" border="0" width="100%">
    <tr>
        <td>
            <table cellpadding="0" cellspacing="0" border="0">

                <tr>
                    <td>name : <input name="ref_name" type="text" size="30" value=""></td>
                </tr>
                <tr>
                    <td>surname : <input name="ref_surname" type="text" size="30" value=""></td>
                </tr>
                <tr>
                    <td>address : <input name="ref_add" type="text" size="30" value=""></td>
                </tr> 
                <tr>
                    <td>tel : <input name="ref_tel" type="text" size="30" value=""></td>
                </tr>   
                <tr>
                    <td>upload : <input type="file" name="ref_img"></td>
                </tr>                                                                   
            </table>
        </td>

        <td>
            <table cellpadding="0" cellspacing="0" border="0">

                <tr>
                    <td>upload2 : <input type="file" name="refree_img"></td>
                </tr>                                                                   
            </table>        
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center" style="padding-top:30px;">
          <input type="submit" Name="Action" value="registration">

          <input type="reset" value="reset" />             
        </td>
    </tr>
</table>

</form>        

</BODY>
</HTML>

1 个答案:

答案 0 :(得分:0)

尝试使用这个简单的代码,只需将“#”替换为您要重定向的网址:

<body bgcolor="#ffffff"> 
<% If Form.State = fsCompletted Then %>

   <p>Saved successfully!</p>
   <script type="text/javascript">setTimeout(function(){ location.href='#'; }, 3000);</script>
<% Else %>
   <!-- Put all your actual html form below-->
   <form>...</form>
<% End If %>
</body>