473,947 Members | 18,894 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

quandry using GET

I have a page that lists a bunch of objects, stored in a database, to
the user. After each object I'd like to do something like:

object1 [edit] [delete]
object2 [edit] [delete]

and so on, where "edit" and "delete" are links. Right now, each link
uses GET to pass the object ID to the scripit that will deal with it.
For example, the urls for the first object links are something like:

edit: http://www.host.com/edit.php?obj=object1
delete: http://www.host.com/delete.php?obj=object1

and similar for the second...you get the idea. This works alright for
the edit option, since it's okay (even advantageous) for a user to
bookmark it. However, it's problematic for the delete option. If a user
bookmarks it, and then tries to visit the site later, they might
unintentionally delete something. I can't use POST since this doesn't
lend itself to a form. I know I could throw some javascript in there to
handle it, but I'm trying to avoid javascript as much as possible.

Does anyone know a better way to do this? Thanks.

Dec 22 '05 #1
5 1247
sw********@yaho o.com wrote:
[...] each link
uses GET to pass the object ID to the scripit that will deal with it.
For example[...]:

edit: http://www.host.com/edit.php?obj=object1
delete: http://www.host.com/delete.php?obj=object1

[...] This works alright for
the edit option, since it's okay (even advantageous) for a user to
bookmark it. However, it's problematic for the delete option. If a user
bookmarks it, and then tries to visit the site later, they might
unintentionally delete something. I can't use POST since this doesn't
lend itself to a form. I know I could throw some javascript in there to
handle it, but I'm trying to avoid javascript as much as possible.

Does anyone know a better way to do this? Thanks.


Can you make delete.php display the object and confirm (with a button)
the deletion?

Dec 22 '05 #2
sw********@yaho o.com wrote:
I have a page that lists a bunch of objects, stored in a database, to
the user. After each object I'd like to do something like:

object1 [edit] [delete]
object2 [edit] [delete]

and so on, where "edit" and "delete" are links. Right now, each link
uses GET to pass the object ID to the scripit that will deal with it.
For example, the urls for the first object links are something like:

edit: http://www.host.com/edit.php?obj=object1
delete: http://www.host.com/delete.php?obj=object1

and similar for the second...you get the idea. This works alright for
the edit option, since it's okay (even advantageous) for a user to
bookmark it. However, it's problematic for the delete option. If a user
bookmarks it, and then tries to visit the site later, they might
unintentionally delete something. I can't use POST since this doesn't
lend itself to a form. I know I could throw some javascript in there to
handle it, but I'm trying to avoid javascript as much as possible.

Does anyone know a better way to do this? Thanks.


You can use POST, so with a form:
<form name="myform" action="action. php" method="POST">

Have two hidden fields:
<input type="hidden" name="act" value="" />
<input type="hidden" name="obj" value="" />

The delete link can then be:
<a href="#" onclick="docume nt.myform.act.v alue='delete';
document.myform .obj.value='obj ect1'; document.myform .submit(); return
false">Delete</a>

Similarly, the edit link can be:
<a href="#" onclick="docume nt.myform.act.v alue='edit';
document.myform .obj.value='obj ect1'; document.myform .submit(); return
false">Edit</a>

You then only need one PHP page to handle edit and delete which just
checks $_POST['act'].

I'll actually suggest putting all this javascript in a function (e.g.
doact(act,obj) which returns false) so the link can just be:
<a href="#" onclick="return doact('delete', 'object1');">De lete</a>

HTH
Robin
Dec 22 '05 #3
Following on from sw********@yaho o.com's message. . .
I have a page that lists a bunch of objects, stored in a database, to
the user. After each object I'd like to do something like:

object1 [edit] [delete]
object2 [edit] [delete]

and so on, where "edit" and "delete" are links. Right now, each link
uses GET to pass the object ID to the scripit that will deal with it.
For example, the urls for the first object links are something like:

edit: http://www.host.com/edit.php?obj=object1
delete: http://www.host.com/delete.php?obj=object1

and similar for the second...you get the idea. This works alright for
the edit option, since it's okay (even advantageous) for a user to
bookmark it. However, it's problematic for the delete option. If a user
bookmarks it, and then tries to visit the site later, they might
unintentionall y delete something. I can't use POST since this doesn't
lend itself to a form. I know I could throw some javascript in there to
handle it, but I'm trying to avoid javascript as much as possible.

Does anyone know a better way to do this? Thanks.

So what? If they really _bookmark_ a delete link who cares - what's
going to explode? Obviously delete.php checks lots of things before
doing anything *because it has to trap lots of other abuse anyway*.

ONE of these tests might be to check you've just come from a page where
deleting is 'on the menu'.
# ---------------------------------------------------------------------
function CheckComeFrom($ PossibleWaysToG etHere,$Destina tion='pp000.php '){
# This is a security function which chucks the user out
# if the refering page is not one of those supplied in the list
# Returns TRUE if all is OK
#
# Put near the top of a script in a not-if {exit;}
# (The actual jump to the destination will be done in this script but
the exit
# is to tidy up any stack of script execution.)
#
# eg if(!CheckComeFr om('foo.php')){ exit;}
#
# Multiple come-froms can be specified by splitting names with a + sign
# eg 'foo.php+bar.ph p+fox.php'
#
# Destination can be overridden. Suppose you want the remote address
put
# onto a blacklist you could send them to putonblacklist. php
#
# This uses $_SERVER['HTTP_REFERER'] which the documention notes
# may not be completely trustworthy.
# ---------------------------------------------------------------------
$cfrom = CameFrom();
$m = '';
if(!$cfrom){
$m='Not referred from anywhere';
$comefrom=$Dest ination;
}else{
$pw = strtolower('+'. $PossibleWaysTo GetHere.'+');
$hit = strpos($pw,'+'. $cfrom.'+');
$rv = (!($hit===FALSE ));
if(!$rv){
// test for reloading page etc which is always allowed
$rv=($cfrom==st rtolower(basena me($_SERVER['PHP_SELF'])));
}
if(!$rv){$m="Fr om:$cfrom";}
}

if($m){
$m .= "<br>Allowed:$P ossibleWaysToGe tHere";
MSG('CheckComeF rom failed','',$m,$ cfrom); // Standard error message
screen
exit;
}
return $rv;
}
# ---------------------------------------------------------------------
function CameFrom(){
# Return the calling page without any base bits or argument bits
# Return '' if no referring page found
# ---------------------------------------------------------------------
if(!isset($_SER VER['HTTP_REFERER'])){
$rv='';
}else{
$comefromfull = basename(strtol ower($_SERVER['HTTP_REFERER']));
$comefrom = explode('?',$co mefromfull); // drop any ?foo=bar bits
$rv = $comefrom[0];
}
return $rv;
}
--
PETER FOX Not the same since the bookshop idea was shelved
pe******@eminen t.demon.co.uk.n ot.this.bit.no. html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.dem on.co.uk>
Dec 22 '05 #4
sw********@yaho o.com wrote:
I have a page that lists a bunch of objects, stored in a database, to
the user. After each object I'd like to do something like:

object1 [edit] [delete]
object2 [edit] [delete]

and so on, where "edit" and "delete" are links. Right now, each link
uses GET to pass the object ID to the scripit that will deal with it.
For example, the urls for the first object links are something like:

edit: http://www.host.com/edit.php?obj=object1
delete: http://www.host.com/delete.php?obj=object1

and similar for the second...you get the idea. This works alright for
the edit option, since it's okay (even advantageous) for a user to
bookmark it. However, it's problematic for the delete option. If a user
bookmarks it, and then tries to visit the site later, they might
unintentionally delete something.


If you don't re-use ID values, then as long as delete.php doesn't format
your hard-drive when asked to delete a non-existent ID value, you're OK,
surely?
--
Oli
Dec 22 '05 #5
Thanks for all your input, guys. To answer Oli and Peter's questions,
you're right. Normally there wouldn't be a problem. I am reusing ID
values, though, so there is the possibility that something could get
accidentally deleted. The input has given me an idea for an approach.
Thanks.

Dec 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1906
by: Jack Carter | last post by:
I have been delegated to produce a tool that has python embedded in it. The desire is to have a command line interface that inherits all the python scripting functionality so people can use the tool either with a flat commandline entry like you would a debugger or with a script using scoping, loops and conditional. I am going from knowing nothing about python to almost nothing so the learning curve is rather
2
1853
by: The Plankmeister | last post by:
Hi, I am converting some queries from stored procedures in MS Access to MySQL, and have hit my first problem. The Access query references another stored procedure, which is where the problem lies. I have the following table data: (apologies if the columns aren't aligned properly... it looks ok in a fixed-width font) img_num img_page img_sect img_order
0
1536
by: The Plankmeister | last post by:
Ello... I have a textarea for user input for which I've (obviously) specified the cols and rows attributes. The object fills its containing <p> snugly until the user changes the text size in the browser. Then the textarea object spills over most horribly. Is there a way using css to override the cols attribute and set an explicit width? I've set its width using css, fixed in px, but this doesn't override the cols attribute when the user...
2
5968
by: rawCoder | last post by:
Hi All, I have a *.cer file, a public key of some one and I want to encrypt some thing using this public key. Can someone point me to a sample code for Encrypting some file using X509Certificate ( *.cer file ) so that it can be used to email as attachment. The real part is Encrypting using X509Certificate and CryptoServiceProvider.
1
567
by: Mike | last post by:
When trying to compile (using Visual Web Developer 2005 Express Beta; frameworkv2.0.50215 ) the source code below I get errors (listed below due to the use of ICallBackEventHandler. Ultimately I want to use a callback from the client side to update webcontrols based on user input without using postback. I am seeking a way to stop the compile errors. using System; using System.Data;
2
1164
by: saiena | last post by:
Is there a way in my regular expression syntax to cause alternating occurences of the search string to be replaced? Here's my code: $item = eregi_replace($search_string, $replace_string, $item); This successfully replaces all occurences of $search_string.
2
1382
by: forums_mp | last post by:
I've come full circle on a design here. Consider the case where I've got two modes of operation, uni-cast or multi-cast. In either mode you can transmit(send) and/or receive. The distinction between the two modes amounts to a set of vendor APIs. When transmitting, to estabilish a connection in uni-cast mode I'll do: openConnection(/*stuff*/); establishUConnection(/*stuff*/);
0
943
by: Ima Loozer | last post by:
I have an application I am coding that includes a report that I want to print to a snapshot and display as a subreport on a form. I want the report to be generated for a 5x7 piece of paper to fit the design layout I am using. It works just fine when I use select my HP All-In-One as the specific printer, but I cannot rely on users of the program having any specific printer installed. I do have the liberty in my coding to install a...
8
1370
by: winterion | last post by:
Hey, I'm working on a curious webpage: http://www.alphachronicles.com It uses IFRAME to seperate content and navigation, opening new pages and such. If someone wanted to link to content, could they? If they link to the content page independently, it's going to look ugly. Any way to have a link bring up the main alphachronicles.com home page, but load the content they want in the IFRAME?
3
8327
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0 build with these methods, will appear to encrypt and decrypt, but the resulting decrypted file will be corrupted. I tried encrypting a .bmp file and then decrypting, the resulting decrypted file under .NET 2.0 is garbage, the .NET 1.1 build works...
0
10164
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9985
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11173
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11352
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10694
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7431
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6118
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6336
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3544
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.