Jump to content


Photo

problem with deleting data from mysql using php


  • Please log in to reply
4 replies to this topic

#1 maxat

maxat
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 08 July 2006 - 10:48 AM

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?

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 08 July 2006 - 11:19 AM

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
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 maxat

maxat
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 08 July 2006 - 11:31 AM

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

#4 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 08 July 2006 - 12:24 PM

Hold on, I'm a little confuse about
<form action="main.php?id=user/delete" method="post">

Shouldn't it be delete.php ?

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#5 maxat

maxat
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 08 July 2006 - 12:50 PM

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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users