Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    48
    Thanks
    28
    Thanked 0 Times in 0 Posts

    update mysql database depending on number typed in a form

    Hi, I am wanting to update mysql database using a form i.e. someone types in unique id i.e. 1234. This then brings up the details for this person from the database etc. But how do I process the form, not sure how to hold the value to search against.. I will be using update and where commands in mysql to search through the database. Any ideas?

    Thanks is advance
    Last edited by Inigoesdr; 12-26-2010 at 10:30 PM.

  • #2
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Why would you use update to search a database?

    Update is the command to edit a table / table row not for searching.

    Select is for selecting rows which *IS* the right way for searching a database.

    I would also suggest using mysql_real_escape_string(); on the return values from the form, for example $type = mysql_real_escape_string($_POST['type']); to stop SQL Injections.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • Users who have thanked DJCMBear for this post:

    tau9 (12-26-2010)

  • #3
    New Coder
    Join Date
    Jan 2009
    Posts
    48
    Thanks
    28
    Thanked 0 Times in 0 Posts
    I managed to get it working, I will add the string thanks for your assistance


  •  

    Posting Permissions

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