Jump to content

Archived

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

maxat

problem with deleting data from mysql using php

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
if instead of delete.php  I use another with plain text inside it displays perfectly, I think there is some problem with  script but i don't know what problem

Share this post


Link to post
Share on other sites
Hold on, I'm a little confuse about
<form action="[b]main.php?id=user/delete[/b]" method="post">

Shouldn't it be delete.php ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.