add new record prob!

Results 1 to 4 of 4

Thread: add new record prob!

  1. #1
    Diane(newbie) Guest

    Default add new record prob!

    I have a submit button on a form that adds a new record to a database. The problem is, as soon as the page is loaded it adds a blank record then adds the new record. I don&#039;t have an if clause in the code. Is there a way to write "if cmd submit = true then....?"<BR>Here is the code I&#039;m using<BR><BR>Mystring = "Select * from Guestbook"<BR> <BR> RS.Open Mystring, conn, adOpenStatic, adLockOptimistic <BR> <BR> RS.MoveLast<BR><BR> RS.Addnew<BR> RS("Name")= request.form("name")& " "<BR> RS("Email") = request.form("email")<BR> RS("Date") = request.form("Date")<BR> RS("Comment") = request.form("comment")<BR><BR> RS.Update<BR> RS.Close<BR> set RS = nothing<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: add new record prob!

    On your form action page, why not look for the value of any of your form collection variables, like so:<BR><BR>if request.form("name") &#060;&#062; "" then<BR>MAKE YOUR RECORD CODE HERE<BR><BR>that way it only inserts if there is a name filled out

  3. #3
    Join Date
    Dec 1969

    Default Querystring

    A lot of people put a querystring variable on the end of their "action" parameter of the form tag. Then, check the querystring variable when the page loads.<BR><BR>If you want to get "fancy", you could write a little JavaScript function to populate a hidden field just before submitting the form. Then, check the field to determine how many times the form has been posted.

  4. #4
    Diane(newbie) Guest

    Default Thanks guys!

    So simple really!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts