Jump to content

problem with deleting data from mysql using php


maxat

Recommended Posts

Hi, I have problem with deleting data from mysql using php my script does work with firefox but not with IE.

<form action="main.php?id=user/delete" method="post">
<td width="10%"><input type="image" src="../images/delete.gif" width="20" height="20" value="<?php echo ($row["id"]) ?>" name="delete" onclick="return confirm('Delete customer from the database?');"></td>
</form>
it is part of a table, inside the table I have few image buttons such as full user info, user ordered products and delete user. For each <td> I made a form, not sure whether it is correct or not, but it does work with firefox.

and delete.php

<?php

if(isset($_POST['delete'])) {
$query = " DELETE FROM user WHERE id = '{$_POST['delete']}' ";

$result = mysql_query($query) or die(mysql_error());
if(mysql_affected_rows() > 0)
echo 'User deleted';
}
?>

Can you help me to make it work with IE?
The only thing i can think of is that the action in your form is being interprited diffrently.. <form action="main.php?id=user/delete" method="post"> firefow may treat it as part of the string but IE could be treating it as a folder on the end, maby try without the slash??

Regards
Liam
This script calls default page to the  body  of main.php 
It is inside of main.php

$id='';
if(isset($_GET['id']))
{
$id = strip_tags($_GET['id']);
}

$inc = 'user/index.php';

if($id != '')
{
$inc = ''.$id.'.php';
}
?>

this is body part of main.php

<div id="content">
   
<?php include($inc); ?>

</div>

inside user/index.php i have list of users with delete button and view info. When i  select "delete" delete.php will be displayed in the body part of main.php with confirmation. To make it possible I  wrote link like 
<form action="main.php?id=user/delete" method="post"> and it works with Firefox.

Archived

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

×
×
  • 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.