very strange...
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=20272
Printed Date: 29 March 2026 at 8:42am Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: very strange...
Posted By: rollerblast
Subject: very strange...
Date Posted: 11 June 2006 at 5:23pm
i have basicly copied the tutorial for writting to a database with asp on this website... and it half works literally!
A new record is created when the form is submitted but there is no data
in the fields! how can this happen!?! here is my code that writes to
the database...
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added
Dim
strSQL
'Holds the SQL query to query the database
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("flashdb.mdb")
'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblFlashinfo.Author, tblFlashinfo.Author_Link,
tblFlashinfo.Title, tblFlashinfo.Entry_Type, tblFlashinfo.Height,
tblFlashinfo.Width, tblFlashinfo.Description, tblFlashinfo.File_Name
FROM tblFlashinfo;"
'Set the cursor type we are using so we can navigate through the recordset
rsAddComments.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsAddComments.LockType = 3
'Open the recordset with the SQL query
rsAddComments.Open strSQL, adoCon
'Tell the recordset we are adding a new record to it
rsAddComments.AddNew
'Add a new record to the recordset
rsAddComments.Fields("Author") = Request.Form("Author")
rsAddComments.Fields("Author_Link") = Request.Form("Author_Link")
rsAddComments.Fields("Title") = Request.Form("Title")
rsAddComments.Fields("Entry_Type") = Request.Form("Entry_Type")
rsAddComments.Fields("Height") = Request.Form("Height")
rsAddComments.Fields("Width") = Request.Form("Width")
rsAddComments.Fields("Description") = Request.Form("Description")
rsAddComments.Fields("File_Name") = Request.Form("File_Name")
'Write the updated recordset to the database
rsAddComments.Update
'Reset server objects
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
'Redirect to the guestbook.asp page
Response.Redirect "guestbook.asp"
%>
have i done something wrong or is it something messing me about?  
|
Replies:
Posted By: Scotty32
Date Posted: 11 June 2006 at 7:02pm
you may need to give alot more information
make sure that you the processing ASP and html form on different pages
also make sure you check the form names with the Request.Form("****")
based on you saying that it creates the record but doesnt have data entered sounds like your html form is wrong
------------- S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins
For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .
|
Posted By: rollerblast
Date Posted: 11 June 2006 at 8:48pm
<form action="flashupload.asp" method="post" enctype="multipart/form-data" name="flashform">
<p> </p>
<p>Author:
<input type="text" name="Author">
</p>
<p>Author Link
<input type="text" name="Author_Link">
</p>
<p>Author Email
<input type="text" name="Author_Email">
</p>
<p>Title:
<input type="text" name="Title">
</p>
<p>
<label> Genre: </label>
<label>
<input type="radio" name="Entry_Type" value="Game">
Game</label>
<label>
<input type="radio" name="Entry_Type" value="Movie">
Movie</label>
</p>
<p> </p>
<p>Height:
<input name="Height" type="text" size="10">
</p>
<p>Width:
<input name="Width" type="text" size="10">
</p>
<p>Description</p>
<p>
<textarea name="Description" cols="40" rows="8"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit" >
</p>
</form>
This is my form code. I cant see any errors . can you?
|
Posted By: Scotty32
Date Posted: 12 June 2006 at 9:40am
spotted the error
<form action="flashupload.asp" method="post" enctype="multipart/form-data" name="flashform"> |
the highlighted part is only ment to be used if your going to be uploading a file AND trying to get info from fields, eg on a gallery if you upload an image and get people to enter a tittle and discription.
when you upload you need to use the upload component to grab the fields values
but it doesnt look like your uploading, so just take out the highlighted area and you should be fine.
id advice you to add more security to your form, maybe javascripts to check if data has been entered or not, so people dont submit a blank form. you should also format the input to the database
if you search on google for " http://www.google.com/search?q=javascript+form+validation - javascript form validation " you'll find some tutorials and sample code
sorry i cant seem to find any on asp security, but try "asp sql injection hacking"
------------- S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins
For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .
|
|