Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How do you delete variables before refreshing page?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How do you delete variables before refreshing page?

Postby TheIceman5 » Tue Jan 21, 2003 9:54 pm

I have a problem with a page im building, i have a list of records with an 'X' on the page, you click the X and it deletes the last record on the page, the query string i use is 'page.php?action=delete' and it works fine, you click it and the page refreshes with the last record gone.
But, when you manually refresh the page with the refresh button it also deletes the last record.
How do i stop it deleting the last record when you manually refresh the page? it obviously is keeping the 'action' variable and passing it back into the page when you refresh it and i dont want that unless you click on the X.
TheIceman5
New php-forum User
New php-forum User
 
Posts: 28
Joined: Tue Jan 21, 2003 9:31 pm

Postby Redcircle » Tue Jan 21, 2003 11:46 pm

I would also include a specific record that you want to delete.

page.php?action=delete&record=24

and set the query like this.

Code: Select all
$query = 'delete form table where id = "'.$_GET['record'].'"';

if there is not record at id 24 then it will not delete anything. so it will only delete something on it's first attempt. remember in your database you should have an auto_incremention field as your primary index which if one is deleted there will never be another with the same index number.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby TheIceman5 » Wed Jan 22, 2003 2:04 pm

wasnt quite as simple as that, i found a solution, i used at the end of the function header("Location: page.php") and it worked perfect.
TheIceman5
New php-forum User
New php-forum User
 
Posts: 28
Joined: Tue Jan 21, 2003 9:31 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron