By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,384 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

making an alert with php

P: n/a
i have this code that when the user click it will delete the record:

echo' <td bgcolor="'.$color.'" width="40"><font face="Verdana"
size="1">
<a href="del.php?id='.$id.'&dbf='.$dbf_new.'">delete</a></
font></td>';

i wanted to do a little confirmation before commiting the action. how
to do it?

tnx

May 23 '07 #1
Share this Question
Share on Google+
13 Replies


P: n/a
shotokan99 wrote:
i have this code that when the user click it will delete the record:

echo' <td bgcolor="'.$color.'" width="40"><font face="Verdana"
size="1">
<a href="del.php?id='.$id.'&dbf='.$dbf_new.'">delete</a></
font></td>';

i wanted to do a little confirmation before commiting the action. how
to do it?

tnx
Wrong group again dude. ;-)

Try comp.lang.javascript.
And it is easy.

Regards,
Erwin Moller
May 23 '07 #2

P: n/a
Message-ID: <46*********************@news.xs4all.nlfrom Erwin Moller
contained the following:
>i have this code that when the user click it will delete the record:

echo' <td bgcolor="'.$color.'" width="40"><font face="Verdana"
size="1">
<a href="del.php?id='.$id.'&dbf='.$dbf_new.'">delete</a></
font></td>';

i wanted to do a little confirmation before commiting the action. how
to do it?

tnx

Wrong group again dude. ;-)

Try comp.lang.javascript.
EEEK! No! If that page ever accidentally got spidered, all the records
would be deleted. Spiders don't run JavaScript, they just 'click'
links.

PHP would be better. I usually pass items to be deleted to an interim
page (store them in a session or hidden field) and ask users to click a
button to confirm the delete.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 23 '07 #3

P: n/a
Geoff Berrow wrote:
Message-ID: <46*********************@news.xs4all.nlfrom Erwin Moller
contained the following:
>>i have this code that when the user click it will delete the record:

echo' <td bgcolor="'.$color.'" width="40"><font face="Verdana"
size="1">
<a href="del.php?id='.$id.'&dbf='.$dbf_new.'">delete</a></
font></td>';

i wanted to do a little confirmation before commiting the action. how
to do it?

tnx
Wrong group again dude. ;-)

Try comp.lang.javascript.

EEEK! No! If that page ever accidentally got spidered, all the records
would be deleted. Spiders don't run JavaScript, they just 'click'
links.

PHP would be better. I usually pass items to be deleted to an interim
page (store them in a session or hidden field) and ask users to click a
button to confirm the delete.
well if a guest user (like a spider) is able to delete you've made
something terrible wrong ;).

Also afaik spider don't execute javascript code.

I use a solution like this:

<a href="#" onclick="gui_delete('delete.php?id=123');">delete</a>
function gui_delete(url)
{
var r = confirm("Delete entry?");
if (r)
{
document.location.href = url;
}
}
May 23 '07 #4

P: n/a
Message-ID: <f3*************@news.t-online.comfrom Joe Scylla
contained the following:
>well if a guest user (like a spider) is able to delete you've made
something terrible wrong ;).
Agreed, but it happens. :-)
>
Also afaik spider don't execute javascript code.

I use a solution like this:

<a href="#" onclick="gui_delete('delete.php?id=123');">delete</a>
function gui_delete(url)
{
var r = confirm("Delete entry?");
if (r)
{
document.location.href = url;
}
}

Fair enough, but I don't like solutions that rely on JavaScript
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 23 '07 #5

P: n/a
En las nuevas, el shotokan99 escribió:
i have this code that when the user click it will delete the record:

echo' <td bgcolor="'.$color.'" width="40"><font face="Verdana"
size="1">
<a href="del.php?id='.$id.'&dbf='.$dbf_new.'">delete</a></
font></td>';

i wanted to do a little confirmation before commiting the action. how
to do it?

tnx

A idea:
$h='';
switch ($_GET['delphase'])
case 'conf':
// Asking for delete
$h.= 'Deleting file '.$id.'?<br>';
$h.= '<a href="del.php?id='.$id.'&dbf='.$dbf_new.'&delphase =delok">OK!</a>
';
$h.= '<a
href="del.php?id='.$id.'&dbf='.$dbf_new.'&delphase =delcancel">Cancel</a>';
break;
case 'delok':
// Answer OK
ulink ($id); // OR whatever you must do to delete the file
$h.= 'File '.$id.' deleted!<br>';
break;
case 'delcancel':
// Answer Cancel
$h = 'Deleting file '.$id.' not done';
// Not breaking to let normal text (default part) show
default:
// Normal behabiour, note the use of delphase parameter
$h.= '<a
href="del.php?id='.$id.'&dbf='.$dbf_new.'&delphase =conf">delete</a>';
break;
}

echo' <td bgcolor="'.$color.'" width="40"><font face="Verdana" size="1">';
echo $h;
echo '</ font></td>';


Hope it works for you.
May 23 '07 #6

P: n/a
How about...

<a href="delete.php?id=123"
onclick="return confirm_delete(this);">delete</a>

function confirm_delete(link)
{
if (confirm("Delete entry?"))
{
link.href += "&sure=1";
return true;
}
else
return false;
}

Where "delete.php" deletes the item instantly if $_GET['sure']==1 and asks
for confirmation otherwise.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 88 days, 18:09.]

The Great Wi-Fi Controversy
http://tobyinkster.co.uk/blog/2007/05/22/wifi-scare/
May 23 '07 #7

P: n/a
Joe Scylla wrote:
well if a guest user (like a spider) is able to delete you've made
something terrible wrong ;).
Think about link prefetching plugins for browsers. Yes, these do exist.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 88 days, 18:15.]

The Great Wi-Fi Controversy
http://tobyinkster.co.uk/blog/2007/05/22/wifi-scare/
May 23 '07 #8

P: n/a
Message-ID: <sl************@ophelia.g5n.co.ukfrom Toby A Inkster
contained the following:
>Where "delete.php" deletes the item instantly if $_GET['sure']==1 and asks
for confirmation otherwise.

Relies on JS being enabled.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 23 '07 #9

P: n/a
Geoff Berrow wrote:
Message-ID: <sl************@ophelia.g5n.co.ukfrom Toby A Inkster
contained the following:
>>Where "delete.php" deletes the item instantly if $_GET['sure']==1 and asks
for confirmation otherwise.

Relies on JS being enabled.
No it doesn't.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 88 days, 22:13.]

The Great Wi-Fi Controversy
http://tobyinkster.co.uk/blog/2007/05/22/wifi-scare/
May 23 '07 #10

P: n/a
Message-ID: <9l************@ophelia.g5n.co.ukfrom Toby A Inkster
contained the following:
>Geoff Berrow wrote:
>Message-ID: <sl************@ophelia.g5n.co.ukfrom Toby A Inkster
contained the following:
>>>Where "delete.php" deletes the item instantly if $_GET['sure']==1 and asks
for confirmation otherwise.

Relies on JS being enabled.

No it doesn't.
What am I missing? It's javascript that appends the 'sure' variable to
the URL and without that delete.php won't do anything.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 23 '07 #11

P: n/a
Geoff Berrow wrote:
What am I missing? It's javascript that appends the 'sure' variable to
the URL and without that delete.php won't do anything.
As I said, when ($_GET['sure']==1) is false, delete.php should display an
"are you sure?" form. (And although I didn't explicitly state it, I meant
that that form should not require Javascript.)

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 89 days, 2 min.]

The Great Wi-Fi Controversy
http://tobyinkster.co.uk/blog/2007/05/22/wifi-scare/
May 23 '07 #12

P: n/a
Message-ID: <25************@ophelia.g5n.co.ukfrom Toby A Inkster
contained the following:
>What am I missing? It's javascript that appends the 'sure' variable to
the URL and without that delete.php won't do anything.

As I said, when ($_GET['sure']==1) is false, delete.php should display an
"are you sure?" form. (And although I didn't explicitly state it, I meant
that that form should not require Javascript.)
But if delete.php is going to handle it like that (and indeed that's how
I'd do it) the Javascript is redundant. It just makes it a little
quicker for people with JS enabled, which is, I'll grant you good use of
JS, but hardly worth the effort in this case IMO.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 23 '07 #13

P: n/a
Geoff Berrow wrote:
Message-ID: <25************@ophelia.g5n.co.ukfrom Toby A Inkster
contained the following:
>>What am I missing? It's javascript that appends the 'sure' variable to
the URL and without that delete.php won't do anything.
As I said, when ($_GET['sure']==1) is false, delete.php should display an
"are you sure?" form. (And although I didn't explicitly state it, I meant
that that form should not require Javascript.)

But if delete.php is going to handle it like that (and indeed that's how
I'd do it) the Javascript is redundant. It just makes it a little
quicker for people with JS enabled, which is, I'll grant you good use of
JS, but hardly worth the effort in this case IMO.
Actually, I think Toby has the right idea. It is worth it to make it
easier for those who have javascript.

Javascript is a great tool - but all pages should degrade gracefully if
it is not enabled. And Toby's method does just that.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 24 '07 #14

This discussion thread is closed

Replies have been disabled for this discussion.