473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

making an alert with php

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
13 2414
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: MT | last post by:
Hi all, this sounds like an easy enough thing to do, but after spending 45 minutes searching google and various javascript sites I can't find out how to make a textfield (textbox or whatever you...
7
by: Christopher Jeris | last post by:
I am relatively new to JavaScript, though not to programming, and I'm having trouble finding the idiomatic JS solution to the following problem. I have a table with (say) fields f1, f2, f3. I...
19
by: Anon Email | last post by:
Hi everyone, Let's see, now. This question is about the capabilities of ANSI C++. I want to write and compile code in ANSI C++ that, when compiled, will make the computer speaker beep; or, at...
3
by: ldixon789 | last post by:
I'm trying to convert an on load event into a function. I think this should be really simple, but I'm new to Javascript. The following works fine as the page loads var favorite =...
7
by: greenflame | last post by:
I am trying to make a matrix object. I have given it some properites. I am trying to add a method. When I call the method by Test.showDims(...) I want to only enter one input, that is the method by...
7
by: Ivo | last post by:
How do I make the magic 'this' variable refer to an object of my choice, in a string of code which is to be eval'ed? Say, I have an object, an array with four elements: var myobject = ; and a...
2
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild,...
4
by: Mystery Man | last post by:
I want to deliberately make a label (and perhaps a button) flash to alert the user that something very serious has happened. Any ideas on how to do this?
2
by: rodchar | last post by:
hey all, i have a button on my web form that after it posts back it suppose to throw up an alert. it works fine but that it throws the alert before the entire page has been displayed. is there any...
24
by: Jeremy J Starcher | last post by:
While reading c.l.j, I've noticed that some people prefer and indeed even recommend the use of "window.alert()" over "alert()". I can't find any technical reason to make this distinction, and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.