2013-12-20 53 views
1

在一個形式的元素創建此richiesta.html:插入使用ASP和保存到DB

<HTML> 
<BODY> 
<table border> //create a simple table 
<tr> 
<td> 
<form ACTION="richiesta.asp"> //open the file richiesta.asp 
<table> //start a table format 
<tr><td><input name="cognome" size="20"/></tr> //contain a input text 
</table> 
</form> 
</td> 
</tr> 
<td><input type="submit" value="Invia"></td><td> // contein a button to send value to DB 
</table> 
</BODY> 
</HTML> 

創建richiesta.asp:

<HTML> 
<BODY> 
<% 
cognome = Request.Form("cognome") 
%> 
<% 
Session.timeout = 1 //Check the session 
If IsObject(Session("iscrizioni")) Then 
Set conn = Session("iscrizioni") 
Else 
Set conn = Server.CreateObject("ADODB.Connection") //Check the connection 
conn.open "iscrizioni" 
Set Session("iscrizioni") = conn 
End If 
%> 
<% 
If Stato = "" Then 
SQL="INSERT INTO iscrizioni (Cognome) VALUES ("SQL=SQL & "'" & cognome & "', "SQL=SQL ") 
response.write(SQL) // 
conn.execute(SQL) // Insert value 
conn.close //Close the connection 
%> 

// // 尾頁 我想插入在BD Anagrafica,表Anagrafica學生的名字。 DB結構: enter image description here

+1

地方提交按鈕表單:) –

回答

2

HTML表單action應該是有效的(相對/絕對)地址和not a physical location

此外,輸入控件和提交按鈕應在默認表單提交的內部表單中。

請改變你的<form>標籤action屬性

<form action="riciesta.asp" > 

<table> 
    <tr><td><input name="cognome" size="20"/></td></tr> 
    <tr><td><input type="submit" value="submit"/></td></tr> 
    </table> 
</form> 
+0

裏面我嘗試在週一的解決方案。 Thamks爲您的可用性:-) –