Create Cookie and write to DB

Results 1 to 2 of 2

Thread: Create Cookie and write to DB

  1. #1
    Join Date
    Dec 1969

    Default Create Cookie and write to DB

    Forgive the ignorance. I&#039ve created a form for visitors to fill out that creates a cookie for page customization. I&#039d like to use the same form to output the required fields to a DB as well as to keep the info in a cookie. For example, the form askes for the visitors email address, below the email input field, I&#039d like a checkbox that if returns true, the email addy would be added to a DB file for use in maintaining newsletter subscriptions. The cookie creation was easy enough, but how do I add part 2? Any help appreciated.

  2. #2 Guest

    Default RE: Create Cookie and write to DB

    &nbsp;<BR>Well, u know that writing the form&#039s contents to the cookie is a certainty. So, all you need to do is then have the script ask whether or not the checkbox is on/off for each of the form&#039s fields (e.g., name, address, colour preference, etc.)<BR><BR>So, after the form is submitted (to a page that performs these checkbox queries), you would employ logic that&#039d work sorta like this:<BR>1] Build a base string for your SQL/database update. Like this<BR>strBase = "INSERT INTO PNote ("<BR>strBase_ante = ") VALUES (&#039"<BR>2] evaluate whether each checkbox is on/off, individually. If the checkbox being examined is on, add that form-field AND record-field to each base string (that you created in step 1). For example:<BR><BR>If name checkbox = 1 THEN<BR> strBase = strBase & "nomen"<BR> strBase_ante = strBase_ante & Request.QueryString("name")<BR>End If<BR><BR>In the above the strings are built upon progressively, with each successive IF statement being true the string is extended upon. But, remember to then (at the end of the checkbox evaluations) to properly close your SQL update string by attaching the closing syntax elements (e.g., "&#039)" )<BR><BR>I don&#039t have any experience in Access/Oracle/etc., so the above might only be worthy for T-SQL stuff.<BR><BR>Hope this helps in some way!<BR>

Posting Permissions

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