Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - very strange...
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

very strange...

 Post Reply Post Reply
Author
rollerblast View Drop Down
Newbie
Newbie


Joined: 07 June 2006
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote rollerblast Quote  Post ReplyReply Direct Link To This Post Topic: very strange...
    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?AngryAngryAngry
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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 - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
rollerblast View Drop Down
Newbie
Newbie


Joined: 07 June 2006
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote rollerblast Quote  Post ReplyReply Direct Link To This Post Posted: 11 June 2006 at 8:48pm
<form action="flashupload.asp" method="post" enctype="multipart/form-data" name="flashform">
  <p>&nbsp;</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>&nbsp;</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?
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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 "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 - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.