Confirming record delete

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Confirming record delete

Post by Illusionist »

can someone tell me whats wrong with this? I'm trignt o maek a confirmation page to check if the user actually wants to delete teh file or not, and im having a little trouble:

Code: Select all

echo "<center>";
echo "<b>Are you sure you want to delete $file?</b><br/>";
echo "<form action=edit.php?file=$file&action=delete method=get><input type=hidden name=yn value=no><input type=submit value=No></form>";
echo "<form action=edit.php?file=$file&action=delete method=get><input type=hidden name=yn value=yes><input type=submit value=Yes></form>";
echo "</center>";
Thanks
Last edited by Illusionist on Thu Feb 12, 2004 6:01 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

What kind of errors, if any are you getting? Provide us with more information, such as edit.php.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

well... i dont get any errors... when i click one fo the submit buttons it atually takes me to edit.php?yn=yes or edit.php?yn=no
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

What the problem then
User avatar
greenhorn666
Forum Commoner
Posts: 87
Joined: Thu Aug 14, 2003 7:14 am
Location: Brussels, Belgium

Post by greenhorn666 »

You can't use the get method...
If you provide params on the action, use a post (which is in this case more appropriate anyhow, won't let the user bookmark for instance)
And be a good programmer (or HTML author rather) use quotes (") for your tag's attributes!
And you should url_encode($file) too, you can't rely on the browser to do that for you...
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Phenom wrote:What the problem then
It supposed to go to

edit.php?file=$file&action=delete&yn=yes

not

edit.php?yn=yes
tsg
Forum Contributor
Posts: 142
Joined: Sun Jan 12, 2003 9:22 pm
Location: SE, Alabama
Contact:

Re: double submits?!

Post by tsg »

You should use hidden tags also for the $file and $action ... not in the URL.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

don't matter i got it fixed. Just liek i wanted it...
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Code: Select all

echo <<<EOT
<b>Are you sure you want to delete $file?</b><br /> 
<a href="edit.php?file=$file&action=delete&yn=no">No</a>
<a href="edit.php?file=$file&action=delete&yn=yes">Yes</a>
EOT;
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

LiLpunkSkateR, thanks but i figured it out already and i didn't want to use links anyways.. thanks
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

then..

Code: Select all

<?php
echo <<EOT
<b>Are you sure you want to delete $file?</b><br />
<form action="edit.php" method="get">
<input type="hidden" name="yn" value="no">
<input type="hidden" name="file" value="$file">
<input type="hidden" name="action" value="delete">
<input type="submit" value="No">
</form>
<form action="edit.php" method="get">
<input type="hidden" name="file" value="$file">
<input type="hidden" name="action" value="delete">
<input type="hidden" name="yn" value="yes">
<input type="submit" value="Yes">
</form>
EOT;
?>
and just a Q, why no links? You could always use an image for the link (ie. <a><img></a>) if you want a button instead of text..
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

like i said, LiLpunkSkateR, thanks for the help, but i figured it out already. no links because i said!
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

i'm sorry, Phenom, let put it behind us get over it, deal?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Illusionist wrote:like i said, LiLpunkSkateR, thanks for the help, but i figured it out already. no links because i said!
- It's good to post the solution if others have the same problem

- Good reason for no having links..
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I have deleted a load of trash out of this thread because flame wars are a waste of bandwidth. In future consider sorting out your differences via the PM system so the rest of us don't have to read that sort of twaddle.

Mac
Post Reply