Jump to content

How To Create A Delete Button?


laczfinador

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>";

Link to comment
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.

Link to comment
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
Link to comment
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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...