Skip to main content
ElizabethGailLittle
Inspiring
November 22, 2020
Answered

Sending parameter after delete

  • November 22, 2020
  • 1 reply
  • 804 views

I have a delete routine that displays contents of a record.  Two buttons - CANCEL & CONFIRM DELETE.  The cancel allows me to send a parameter with the header("Location ...) and all is well.  When I choose confirm delete, the record is deleted, but the value of the parameter is cleared.  I have set the parameter to a value in the record WHEN THE RECORD IS READ.  Nothing in the delete routine changes the independent value, but it gets cleared when the record is deleted.  Is there any way to preserve a value in the record before it's deleted?  I have a table with a large # of records.  After deleting, I want to return to the display of the selected subset.  

 

I'm setting a variable $CycleYear = $r_Cycle_Year which is set when the field r_Cycle_Year is bound to $r_Cycle_Year.  Why does $CycleYear get cleared when the record is deleted?  I understand that all record values are undefined after deletion, but why can't I preserve a value for use as a parameter?

 

Thanks for any advice!

This topic has been closed for replies.
Correct answer BenPleysier

To me, it sounds like the delete fuction refreshes the page or leads to another page. In either case , the variable will be lost. There are a number of ways to preserve the value of the variable. Have a look at https://www.w3schools.com/html/html5_webstorage.asp. Another way is to use a session variable.

1 reply

BenPleysier
Community Expert
BenPleysierCommunity ExpertCorrect answer
Community Expert
November 22, 2020

To me, it sounds like the delete fuction refreshes the page or leads to another page. In either case , the variable will be lost. There are a number of ways to preserve the value of the variable. Have a look at https://www.w3schools.com/html/html5_webstorage.asp. Another way is to use a session variable.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
ElizabethGailLittle
Inspiring
November 23, 2020

After the delete, I'm calling

header("Location: DisplayRCL.php?CycleYear=$CycleYear);

When the Cancel button is selected, this command is sent successfully.

When the Confirm Delete button is selected, $CycleYear is null.

Why?

 

 

BenPleysier
Community Expert
Community Expert
November 23, 2020
header("Location: DisplayRCL.php?CycleYear=$CycleYear);

This creates a new HTTP request and discards the old. See my solution above.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!