#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    2
    Rep Power
    0

    Variable Undefined


    I haven't done CF in a long time but I didn't think I'd have issues with this simple task. I'm using a simple form, simple table in a database, & simple <cfquery> with insert statement. I can't figure out this issue.

    My form code (portion):
    <form action="submitform.cfm" method="post" name="sponsorform">
    <table border="0">
    <tr>
    <td>First Name: </td>
    <td> <input type="text" name="firstname" size="50" /></td>
    </tr>
    </table>
    </form>

    My QUERY.
    <cfquery name="sponsorsubmit" datasource="webmas5_sponsor">
    INSERT INTO sponsorship
    (firstname, lastname, email, hittype, amount, maxamount, message)
    VALUES ('#sponsorform.firstname#', '#sponsorform.lastname#', '#sponsorform.email#', '#sponsorform.hittype#', '#sponsorform.amount#', '#sponsorform.maxamount#', '#sponsorform.message#')
    </cfquery>

    I'm getting that 'firstname' is UNDEFINED. I've done a dump of the form and that comes back as empty.

    I feel stupid because I can't figure this out!!
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,275
    Rep Power
    968
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    2
    Rep Power
    0
    That wasn't it actually.

    I had to add <cfparam> on the form page and set the variable to "". That made it work. I don't know if it is because of newer versions of CF - I had never used that in the past.
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,275
    Rep Power
    968
    No, that should not be necessary. If you do a

    <cfdump var="#form#"><cfabort>

    on the submitform.cfm action page, you will see all of the form fields that were submitted. If you don't, then something else is wrong.

    Originally Posted by webmastermama
    That wasn't it actually.

    I had to add <cfparam> on the form page and set the variable to "". That made it work. I don't know if it is because of newer versions of CF - I had never used that in the past.

IMN logo majestic logo threadwatch logo seochat tools logo