- Forums
- HTML
- Link Html Form With Access Database Using .ASP Script Code
i have created an html form and linked it with database and a asp page. the html coding is now when i press the submit button in the html form, the asp coding appears in the browser and data is not sent to the database [767], Last Updated: Sat May 18, 2024
fahad
Sun Apr 17, 2011
1 Comments
1514 Visits
i have created an html form and linked it with database and a asp page. the html coding is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br><br><html><br><head><br> <style><br> td { font-size : 8pt; font-family : Verdana, Arial; text-decoration : none; }<br> body { font-size : 8pt; font-family : Verdana, Arial; text-decoration : none; }<br> input { font-size : 8pt; font-family : Verdana, Arial; height : 17; }<br> </style><br></head><br><br><body><br><form action="form_ac.asp" method="post"><br><p align="center"><b>HTML Form Page:</b></p><br><table align="center" border=0 cellpadding=3 cellspacing=3 cols=2 width=400><br><tr><br> <td align="right" height=10 valign="top">Name :</td><br> <td align="left" height=10 valign="top" width=250><input type="text" name="name"></td><br></tr><br><tr><br> <td align="right" height=10 valign="top">Email :</td><br> <td align="left" height=10 valign="top" width=250><input type="text" name="email"></td><br></tr><br><tr><br> <td align="right" height=10 valign="top">Country :</td><br> <td align="left" height=10 valign="top" width=250><input type="text" name="country"></td><br></tr><br><tr><br> <td align="right" height=10 valign="top">Comments :</td><br> <td align="left" height=10 valign="top" width=250><textarea cols=20 rows=5 name="comments"></textarea></td><br></tr><br><tr><br> <td align="right" height=10 valign="top"></td><br> <td align="left" height=10 valign="top" width=200><input type="submit" value=" "> Submit -></td><br></tr><br></table><br></form><br><br></body><br></html><br><br><br><br>the asp coding is given below<br><br><br><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br><br><html><br><head><br></head><br><br><body><br><%<br> ' Declaring variables<br> Dim name, email, country, comments, data_source, con, sql_insert<br><br> ' A Function to check if some field entered by user is empty<br> Function ChkString(string)<br> If string = "" Then string = " "<br> ChkString = Replace(string, "'", "''")<br> End Function<br><br> ' Receiving values from Form<br> name = ChkString(Request.Form("name"))<br> email = ChkString(Request.Form("email"))<br> country = ChkString(Request.Form("country"))<br> comments = ChkString(Request.Form("comments"))<br><br> data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _ <br> Server.MapPath("form.mdb")<br> sql_insert = "insert into users (name, email, country, comments) values ('" & _<br> name & "', '" & email & "', '" & country & "', '" & comments & "')"<br> <br> ' Creating Connection Object and opening the database<br> Set con = Server.CreateObject("ADODB.Connection")<br> con.Open data_source<br> con.Execute sql_insert<br> ' Done. Close the connection<br> con.Close<br> Set con = Nothing<br> Response.Write "All records were successfully entered into the database."<br> %><br><br><br><br></body><br></html>
now when i press the submit button in the html form, the asp coding appears in the browser and data is not sent to the database. plz help. my entire work is uploaded as attachment
usually i work in Linux systems, since .asp is not open source, the support is limited to specialized communities and difficult to find for free. if i knew asp i would help you, but i have no idea, but if it was PHP, you would just simply check the value of the submit button to make sure you have a value for example in the variable:
$_POST['Submit']
like this:
if($_POST['Submit']) echo 'form submitted'
https://www.wallpaperama.com/forums/_wxxlwe.html