Enter-Update same form


<--- Your basic HTML form with two boxes for first and last name --->

<html>
    <head>
        <title></title>
    </head>

    <body>

    <center>

        <form method="POST" action="newposition.cfm">
            <font face="Century Gothic" size="2">
                First: <input type="text" name="firstname">
                <br>
                Last: <input type="text" name="lastname" size="20" tabindex="2">
                <br>
                <input type="submit" value="Submit" name="B1" tabindex="3">
            </font>
        </form>

    </body>
</html>


<--- NEW FILE: newposition.cfm --->
<--- First you insert the three basic parts, or two, or just one. Here I do three. --->

<cfquery name="[ queryname ]" datasource="[ dsn ]">
    INSERT INTO [ tablename ]
                    (
                        firstname,
                        lastname,
                        organization
                    )
                    VALUES(
                        '#firstname#',
                        '#lastname#',
                        'National Council'
                    )
</cfquery>

<--- Then we grab the highest ID from the DB, which should be what was just entered --->

<cfquery name="[ queryname ]" datasource="[ dsn ]">
    SELECT MAX(ID)as newmem
    FROM [ tablename ]
</cfquery>

<--- Now we go to the edit form to edit the information related to the highest ID --->

<CFLOCATION URL="[same file as used for updates].cfm?id=#[queryname].newmem#">



All ColdFusion Tutorials By Author: Rhino
  • Auto Event Emailer
    Queries the database everyday and sends an email automatically when certain events happen.
    Author: Rhino
    Views: 15,779
    Posted Date: Friday, December 13, 2002
  • Column View Output
    Ever wanted your data to be output in a column view such as mailing labels are? Use this code and change only a few lines and your data will be output in a table with 3 columns and as many rows as you have data. A great alternative to the standard row based view. Very easy to modify.
    Author: Rhino
    Views: 8,128
    Posted Date: Wednesday, February 25, 2004
  • Count Down
    Easy CFM file that counts down from a distant date to the present. Can show how many days, months, or years.
    Author: Rhino
    Views: 12,921
    Posted Date: Friday, December 13, 2002
  • Enter-Update same form
    I hate creating duplicate forms where one is for entry and an identical one is for udpating. This code lets you use one form for both purposes.
    Author: Rhino
    Views: 10,086
    Posted Date: Wednesday, April 7, 2004
  • Form processor with individual link email
    This tutorial shows how to process a form and generate a random string that is put on the end of a link. When the user clicks the link it goes to their personal page.
    Author: Rhino
    Views: 10,246
    Posted Date: Wednesday, March 31, 2004
  • Form with 2 Submit Buttons
    An easy way to have a form with 2 or more submit buttons where each one does a different thing. One can count a rows in a DB, then next can actually submit the query. Possibilities are limitless.
    Author: Rhino
    Views: 14,369
    Posted Date: Monday, October 9, 2006
  • IP checker
    Checks to see where the user came from and then decides where to send them.
    Author: Rhino
    Views: 13,788
    Posted Date: Friday, December 13, 2002
  • Use checkboxes on update pages
    Do you have an update page and want to use checkboxes on the page? This tutorial will go over the two steps needed.
    Author: Rhino
    Views: 9,829
    Posted Date: Wednesday, March 31, 2004
  • User Authenication - ADMIN area
    This script provides a simple admin area for the login script written by Pablon on this site. You can list, add, change pass, and delete users.
    Author: Rhino
    Views: 12,318
    Posted Date: Monday, March 29, 2004
  • Website Monitor
    Do you have a website that you'd like to monitor but would rather not pay outrageous fees to some company? This simple script will monitor uptime for you website. It is the barebones version and can be easily modified into something highly useful.
    Author: Rhino
    Views: 12,571
    Posted Date: Wednesday, March 24, 2004