Jump to content
Sign in to follow this  
laczfinador

How To Create A Delete Button?

Recommended Posts

Hello World!I am somewhat inexperienced in PHP and have stumbled upon a problem. I have a nice .php script that shows us the contents of a database table, one row per database entry. I wish to create an edit/delete button at the end of each row. I came up with a quick solution: why not use links and forward the variables with a query string to the edit/delete php script? Well, I figured, that this might not be the most secure option, because the href attribute is viewable by anyone... my question is: can anyone introduce me to some more sophisticated ways of achieveng this goal?Here is the code I am using:

require("mysql_connect.php");//This page is accessible through a search form.//If the user left the username field empty,//every user should be listed. There will be//an else statement where pattern matching is used...if($_GET['username']==""){	$sql="SELECT * FROM users";	$result=mysql_query($sql);}while($row=mysql_fetch_row($result)){echo $row[1]." - ".$row[2]."(".$row[3].")<br />";}echo "<a href=\"newuser.htm\">back</a>";

Edited by laczfinador

Share this post


Link to post
Share on other sites

Hey there gar onn!Unfortunatelly that is not the case... I need to hand-code this operation on a webpage, so that someone non-technical can edit the database entries - but thanks anyways, phpmyadmin is indeed a great application!:)

Share this post


Link to post
Share on other sites

A link to the edit/delete script is fine, you can always check the user's permissions at the start of the linked script.

Share this post


Link to post
Share on other sites
A link to the edit/delete script is fine, you can always check the user's permissions at the start of the linked script.
Can you tell me how to cheack for the login

Share this post


Link to post
Share on other sites
$user = (isset($_SESSION['user'])) ? $_SESSION['user'] : "";// or whatever method you use to check if a user is logged inif ($user) {  // whatever you want to do here}

If you do have a permissions level, then you would have to query the database, retrieve it and pass it through an IF statement.

Edited by RahXephon

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...