6 Replies - 349 Views - Last Post: 14 January 2020 - 10:13 AM Rate Topic: -----

#1 twjordan29   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-December 19

My update table form is deleting a row instead of updating a row...

Posted 27 December 2019 - 07:42 PM

I have a CAD script I am working on for a friend of mine. I created an update database script so that we can update data in that certain table. There are 7 columns in the table, 3 of which are updateable. Every time I modify the fields via the PHP form and click update, 6 of 7 tables update successfully while the other one deletes any data that was in it prior to updating the form. The field that is deleting data is disabled so it cannot be edited regardless. However, it deletes itself upon clicking the button.

Here is the script (I had to post images due to DIC Cloudflare blocking me from posting PHP code)... Am I missing something? (the field that deletes itself upon clicking the button is the rp_name field).

https://prnt.sc/qgnvcy

https://prnt.sc/qgnvge

https://prnt.sc/qgnvm1

Is This A Good Question/Topic? 0
  • +

Replies To: My update table form is deleting a row instead of updating a row...

#2 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3826
  • View blog
  • Posts: 13,946
  • Joined: 08-August 08

Re: My update table form is deleting a row instead of updating a row...

Posted 28 December 2019 - 05:53 PM

Deprecated MySQL functions are simpler to use (not counting all the sanitizing you need to add) than PDO or MySQLi prepared statements, but far less secure. That's why they've been deprecated. If you're just learning PHP you should start with
http://www.dreaminco...duction-to-pdo/
or
http://php.net/manua...-statements.php
When dealing with old code that uses deprecated MySQL functions you should replace them if possible. If it's not possible, your experience with PDO or MySQLi will benefit you when dealing with MySQL functions.
Was This Post Helpful? 0
  • +
  • -

#3 Ornstein   User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 64
  • Joined: 13-May 15

Re: My update table form is deleting a row instead of updating a row...

Posted 29 December 2019 - 05:20 AM

At first glance: You've got the "disabled" attribute on the form inputs - which means the browser shouldn't/won't submit that value - so $_POST['rp_name'] should/will be empty.

This post has been edited by Ornstein: 29 December 2019 - 05:23 AM

Was This Post Helpful? 0
  • +
  • -

#4 benanamen   User is offline

  • D.I.C Head

Reputation: 36
  • View blog
  • Posts: 244
  • Joined: 28-March 15

Re: My update table form is deleting a row instead of updating a row...

Posted 29 December 2019 - 10:34 AM

I would like to help you but I am having a heck of a time trying to paste the picture of your code into my editor.
Was This Post Helpful? 0
  • +
  • -

#5 RobHowdle   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 48
  • Joined: 03-December 19

Re: My update table form is deleting a row instead of updating a row...

Posted 14 January 2020 - 03:14 AM

You've got no action within your form that is submitting the data? Not sure why it would be deleting but I would have thought without telling the form what to do via an action it just simply shouldn't update? Any forms I've done in PHP when I haven't put an action in IE "handling.php" or something the form itself just doesn't submit. Have you tried adding that in?

Rob
Was This Post Helpful? 0
  • +
  • -

#6 benanamen   User is offline

  • D.I.C Head

Reputation: 36
  • View blog
  • Posts: 244
  • Joined: 28-March 15

Re: My update table form is deleting a row instead of updating a row...

Posted 14 January 2020 - 10:04 AM

View PostRobHowdle, on 14 January 2020 - 03:14 AM, said:

You've got no action within your form that is submitting the data? Not sure why it would be deleting but I would have thought without telling the form what to do via an action it just simply shouldn't update? Any forms I've done in PHP when I haven't put an action in IE "handling.php" or something the form itself just doesn't submit. Have you tried adding that in?

Rob


Rob, There is nothing wrong with leaving the action out to submit to the same page and is the cleanest way to do it. It is well known certain versions of IE would not submit if you coded the page improperly by depending on the name of a submit button for the script to work. If you had checked the REQUEST METHOD instead, you would not have had a problem.
Was This Post Helpful? 0
  • +
  • -

#7 Ornstein   User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 64
  • Joined: 13-May 15

Re: My update table form is deleting a row instead of updating a row...

Posted 14 January 2020 - 10:13 AM

I feel like I already solved this one. :P
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1