Jump to content

Recommended Posts

guys im trying to add up a action to delete all table if needed else delete row according to id.

 

 

i added

 

if($act==del){

mysql_query("DROP TABLE survey") or die(mysql_error());

}

 

this should execute only if i make the url like del.php?act=del else only the DELETE FROM survey WHERE id = '$id' should work. tell me if its the right way

 

 

<?php
$id =$_REQUEST['id'];    
$user = $login->username;
if($user =='administrator'){
   // sending query
   mysql_query("DELETE FROM survey WHERE id = '$id'")
   or die(mysql_error());    
   header("Location: status.php");
}else{
    header("Location: logout.php");
}
if($act==del){
mysql_query("DROP TABLE survey") or die(mysql_error());    
}

?>

Link to comment
https://forums.phpfreaks.com/topic/270831-is-this-right-actdel/
Share on other sites

1. Check that $_REQUEST['id'] is set and is an integer before using it, right now your code is open to SQL injection.

 

2. Where is $act coming from?

 

3. del is assumed to be a constant value without the value wrapped in quotes.

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.