I don't even know where to start...

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
Restrikted
Forum Newbie
Posts: 6
Joined: Sun Jun 01, 2008 10:37 pm

I don't even know where to start...

Post by Restrikted »

Sorry for posting another thread in such a short time, but I am just baffled with where to start with the coding on this one. Basically, what I want to do is to let people add an entry, which gets stored in a database. However, I also want them to be able to edit/delete that entry at their whim, but let's just focus on deleting it for now. The problem is, the person can add multiple entries and I need the ability to dynamically add a link for each entry in someone's profile, which can effectively delete that specific entry. I am just in awe with where to start as I have only been coding for about a month. Basically the way I see it, I need to be able to dynamically create a link which is specific to that one entry, and when clicking on it, executes the mysql command. Anyone willing to take a shot at how I could accomplish this?
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: I don't even know where to start...

Post by tecktalkcm0391 »

First query the database for the users's posts... then run a loop that prints a link with a get parameter that another PHP could get, check to make sure that its the users's post, then delete it...
User avatar
Frozenlight777
Forum Commoner
Posts: 75
Joined: Wed May 28, 2008 12:59 pm

Re: I don't even know where to start...

Post by Frozenlight777 »

There is an exact tutorial on how to do this with every php book I own.
Restrikted
Forum Newbie
Posts: 6
Joined: Sun Jun 01, 2008 10:37 pm

Re: I don't even know where to start...

Post by Restrikted »

I don't own any php books, I mainly go off of the tutorials and sample code and learn from that. Okay, I can now change the url's and return certain values if the person clicks it. However, I'm basically just creating a link back to the original page with a certain value added on with GET. An obvious problem presents itself with this however, since if someone was logged in and moves forward in the site and hits the back button, another entry will be deleted. I'm not asking for code on this, but how do you think I should go about making sure this doesn't happen? I'd try to create a pop-up, but most people have pop-up blockers. Should I send them to another page and have them confirm that they want to delete it?
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: I don't even know where to start...

Post by tecktalkcm0391 »

Each entry in the database should have an ID that is auto incremented meaning its added automatically to each row... when you delete a entry it should be by that unique id so that you only delete that one row... make sure that you validate that the ID is matched to the user that posted it because if not you will have a security hole.
Post Reply