0

I have remove which is given as a link. If I click remove I want to remove a value from the database, but certainly its not working... what's wrong?

<td align="center">
<div id="remove">
<a href='#' onclick="removeDesign()">remove</a>
</div>
</td> 

function removeDesign()
{
var confirmation = confirm("Are You Sure You Want to Delete This Item?")
if(confirmation == true)
{
  $.post('remove.php',{designId : [<?=$_SESSION['designid']?>]});
}
}

remove.php:

<?php

include("config/dbconn.php");
$DesignId=$_POST['designId'];
$sql = "delete from design where id = '".$DesignId."'";
mysql_query($sql);
?>

The problem is the designid value is not passing to the remove.php? Can any one show the solution?

2
  • 1
    Your code screams of a SQL Injection vulnerability. Commented Jun 21, 2011 at 11:06
  • Right now, it's a good thing that this doesn't work, because it's an enormous SQL injection hole. Imagine if someone submitted ' OR '' = ' as designId -- all the records in your database would be gone. Sanitise the data, and look into using prepared statements. Commented Jun 21, 2011 at 11:07

1 Answer 1

1

Try

$.post("remove.php",{designId : "'" +  <?php echo $_SESSION['designid']?> + "'"} );
Sign up to request clarification or add additional context in comments.

1 Comment

and make sure php sort tag is enabled

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.