wood burning stoves 2.0*
The moose likes PHP and the fly likes problem in deleting data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » PHP
Bookmark "problem in deleting data" Watch "problem in deleting data" New topic
Author

problem in deleting data

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1001
    
    2
hello everyone i m writing code for deleting data, but i have a problem in that,
well the scenario is like this:

i have three pages, my pages has two submit buttons and on action i m calling the delete.php (my delete.php is one file in which i am checking for post, ie.



these two works fine for me, but my third page has two buttons (not submit) one for delete one for approve, so i cannot redirect to delete.php using form action,
so i m redirecting from here to delete.php with js, and also i m passing the id number with url, whose record want to delete...
now my question is how to check post for this in delete.php

if i do like this:

if($_POST('button3'))
{
//code for delete whose button name is button3
}

if i do like this it's an error because i m not using post here, so how to do this???

Nick Charles
Ranch Hand

Joined: Oct 09, 2011
Posts: 71

I think that you are mixing up funjctionality with web pages. Instead, try this: have a web page for each different type of data that you want to display/input, and define a PHP page for each. Then have separate php include pages that know how to do things such as update the database, query the database, delete things in the database. The form input should lead to a php file that knows how to process the input. That file should examine the button clicked and invoke the correct funtions in the pages that perform the database handling.

What books have you read about PHP so far? Most should really cover this topic with various best practices.
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1001
    
    2
this i have also done, i have created one more page say delete1.php for the page in which i have two buttons, and i m passing my id Id to delete1.php by url and getting id in delete1.php and performing query based on that id..
but now anyone can change id into url and operation/query will perform because posting of data is not check here..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in deleting data