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

    Join Date
    Jun 2012
    Posts
    153
    Rep Power
    13

    Struggling with php edit/update form


    Hi

    I got two issues I think

    I got a edit.php page and it has a form that should update a mysql record but it is not doing so

    If I don't select any active or inactive radio button, I get the following error

    Notice: Undefined index: status in /home/sites/irhwebsites.com/public_html/sites/sgr/admin/edit.php on line 18

    If I do select a active or inactive radio button, the form just resets itself and does nothing

    I have pasted the coding from the edit.php into pastebin and included the link below

    http://pastebin.com/zwqpGMw9

    just can't work out where it is going wrong

    Thank you in advance

    Ian
  2. #2
  3. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,111
    Rep Power
    487
    Aside from the bad inclusion of $_GET in your SQL, have you tried printing any debugging info to screen?

    For example, if you use the line

    print_r($_GET);

    you can see what is being sent, check that the data types is present and in the correct format for the update (i.e. numbers / strings etc)
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  4. #3
  5. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,111
    Rep Power
    487
    oh, by the way, your form is sending data using POST but you have a line in the UPDATE statement that says "WHERE id = '" . $_GET['id'] . "'";"

    If you need to use the ID variable then add a hidden field to the form with the name "id" and the value of $_GET['id'], then modify your SQL to read:

    WHERE id = '" . $_POST['id'] . "'";

    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984

IMN logo majestic logo threadwatch logo seochat tools logo