Treehouse: Grow your CSS skills. Land your dream job.

Making an edit entry form for a database

  • # April 15, 2011 at 1:18 am

    Hi Folks,

    I am just out of interest messing around with PHP trying to make a form which will edit an entry in the database. would this be the right way to go about it?

    What i’ve done is used the GET function to collect the ID of the entry then passed that into the form action URL

    # April 18, 2011 at 4:20 am

    Hello, I also had some problems with making the entry in database. I am not good in coding, so i spent plenty of time trying to write it corrrectly, but I just wasted my time. I asked my friend who recently made a great personal web site, and he advised me to find a program that will build a form itself, as for me, I found phpforms, and now everything is ok.

    # April 18, 2011 at 11:00 am

    What you have suggested seems fine.

    Just a quick bullet point list of things to do.

    The list is displayed somewhere. The URL has the ID of the entry in a get variable.
    In your page do a query to find all the info for that entry. the sql query would be something like

    Now run through the building the form inside a while loop. Use the while loop to fill in the form value fields.

    Now in the update page,
    Collect all the variables and name them properly.
    Now clean up the variables (Lookup sql injection if you’re not sure)
    Now update the table like
    UPDATE YOURTABLE SET field1=’$field1′, field2=’$field2′ WHERE ItemID=’$_GET

    And that should be that

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.