Hi Every Body
I have a samll piece of code written in php my problem is code is not deleting record from my database. Please see the code below which is calling deleteadministratorexe.php - which is actually deleting the record. Files are attached here -

<?php
require_once('security.php');
require_once('connection.php');
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Index</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style5
 {
	font-size: 9px;
	color: #FF9900;
	font-weight: bold;
 }
-->
</style>
<script type="text/javascript" >function fo(){viby.dtext.focus();}</script>
</head>
<body onload="fo();">
<h1>Welcome <font color="#FF6600"><?php echo $_SESSION['loginname']; ?></font></h1>| <a href="logout.php">Logout</a>
<p>This is a password protected area only accessible to members. </p>
<div align="center">
<form name="viby" method="post" action="">
  <table width="366" border="1">
    <tr>
	  <td><h2 class="style5">ENTER CUSTODIAN ID</h2></td>
      <td><input name="dtext" type="text" /></td>
      <td><input type="submit" name="Submit" value="VIEW" /></td>
    </tr>
  </table>
</form>
</div>
<form method="post" action="deleteadministratorexe.php">
<table width=100% border=1>
  <tr>
    <td width=42 height=28 bgcolor=#FFFF99>ID</td>
    <td width=61 bgcolor=#FFFF99>CODE</td>
    <td width=77 bgcolor=#FFFF99>Password</td>
    <td width=92 bgcolor=#FFFF99>Departmenet ID </td>
    <td width=77 bgcolor=#FFFF99>E-Mail</td>
    <td width=108 bgcolor=#FFFF99>Security Level </td>
    <td width=81 bgcolor=#FFFF99>Last Login </td>
    <td width=92 bgcolor=#FFFF99>Account ID </td>
    <td width=75 bgcolor=#FFFF99>Customer Name </td>
    <td width=77 bgcolor=#FFFF99>Customer Rank </td>
    <td width=123 bgcolor=#FFFF99>Customer PH </td>
  </tr>
<?php
if (isset($_POST['dtext']))
{
$qry = "SELECT * FROM users_table where cust_id = $_POST[dtext]" or die("Display Error: ".mysql_error()); 
$result = mysql_query($qry); 
    while($row=mysql_fetch_array($result))
    {
     echo " <tr>
       <td><input name=t1 type=text id=t14 value=$row[0] ></td>
       <td><input name=t2 type=text id=t2 value=$row[1] ></td>
       <td><input name=t3 type=text id=t3 value=$row[2] ></td>
       <td><input name=t4 type=text id=t4 value=$row[3] ></td>
       <td><input name=t5 type=text id=t5 value=$row[4] ></td>
       <td><input name=t6 type=text id=t6 value=$row[5] ></td>
       <td><input name=t7 type=text id=t7 value=$row[6] ></td>
       <td><input name=t8 type=text id=t8 value=$row[7] ></td>
       <td><input name=t9 type=text id=t9 value=$row[8] ></td>
       <td><input name=t10 type=text id=t10 value=$row[9]></td>
       <td><input name=t11 type=text id=t11 value=$row[10]></td>
     </tr>";
    }
}
?>
 <tr>
   <td height="23" colspan="6"><input align="right" name="RESET" type="reset" id="RESET" value="Reset" /></td>
   <td colspan="5"><input align="left" name="DELETE" type="submit" id="DELETE" value="Delete" /> </td>
  </tr>
</table>
</form>
||<a href="member.php"> GO TO INDEX</a>
</body>
</html>

i think query has to change...
in deleteadministratorexe.php

$qry = "delete from `users_table` where cust_id='$str'";
$qry = "delete from `users_table` where cust_id=$str";

i think query has to change...
in deleteadministratorexe.php

$qry = "delete from `users_table` where cust_id='$str'";
$qry = "delete from `users_table` where cust_id=$str";

Hi Rohit

Thankyou for your concederation but you soluton didn't work, can you give any another solution

there is one thing, you have two form in your code due to whick in
deleteadministratorexe.php the value of str is not comming.. write only one form tag.....

check these code working fine on my pc.i have made some little changes include javascript,,, only one form there ...apply it

<?php
require_once('config.php');
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Index</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style5
 {
	font-size: 9px;
	color: #FF9900;
	font-weight: bold;
 }
-->
</style>
</head>
<body >
<form name="frmshow" id="frmshow" method="post" onSubmit="javascript:decide_action();">
<h1>Welcome <font color="#FF6600"><?php echo $_SESSION['loginname']; ?></font></h1>| <a href="logout.php">Logout</a>
<p>This is a password protected area only accessible to members. </p>
<div align="center">
  <table width="366" border="1">
    <tr>
	  <td><h2 class="style5">ENTER CUSTODIAN ID</h2></td>
      <td><input name="dtext" type="text" id="dtext" /></td>
      <td><input type="submit" name="View" id="View" value="VIEW"  onClick="document.pressed=this.value"/></td>
    </tr>
  </table>
</div>
<table width=100% border=1>
  <tr>
    <td width=42 height=28 bgcolor=#FFFF99>ID</td>
    <td width=61 bgcolor=#FFFF99>CODE</td>
    <td width=77 bgcolor=#FFFF99>Password</td>
    <td width=92 bgcolor=#FFFF99>Departmenet ID </td>
    <td width=77 bgcolor=#FFFF99>E-Mail</td>
    <td width=108 bgcolor=#FFFF99>Security Level </td>
    <td width=81 bgcolor=#FFFF99>Last Login </td>
    <td width=92 bgcolor=#FFFF99>Account ID </td>
    <td width=75 bgcolor=#FFFF99>Customer Name </td>
    <td width=77 bgcolor=#FFFF99>Customer Rank </td>
    <td width=123 bgcolor=#FFFF99>Customer PH </td>
  </tr>
<?php
if (isset($_POST['dtext']))
{
$qry = "SELECT * FROM tfarmact where ActvID = $_POST[dtext]" or die("Display Error: ".mysql_error()); 
$result = mysql_query($qry); 
    while($row=mysql_fetch_array($result))
    {
     echo " <tr>
       <td><input name=t1 type=text id=t14 value=$row[0] ></td>
       <td><input name=t2 type=text id=t2 value=$row[1] ></td>
       <td><input name=t3 type=text id=t3 value=$row[2] ></td>
       <td><input name=t4 type=text id=t4 value=$row[3] ></td>
       <td><input name=t5 type=text id=t5 value=$row[4] ></td>
       <td><input name=t6 type=text id=t6 value=$row[5] ></td>
       <td><input name=t7 type=text id=t7 value=$row[6] ></td>
       <td><input name=t8 type=text id=t8 value=$row[7] ></td>
       <td><input name=t9 type=text id=t9 value=$row[8] ></td>
       <td><input name=t10 type=text id=t10 value=$row[9]></td>
       <td><input name=t11 type=text id=t11 value=$row[10]></td>
     </tr>";
    }
}
?>
 <tr>
   <td height="23" colspan="6"><input align="right" name="RESET" type="reset" id="RESET" value="Reset" /></td>
   <td colspan="5"><input align="left" name="DELETE" type="submit" id="DELETE" value="Delete"  onClick="document.pressed=this.value"/></td>
  </tr>
</table>
||<a href="member.php"> GO TO INDEX</a>
</form>
</body>
</html>
<SCRIPT language="JavaScript">
function decide_action() {
x = document.pressed
	if (x == "Show") 
		{
		myname =document.forms['frmshow'].elements['View'].value;
		document.frmshow.action ="<?php echo $_SERVER['PHP_SELF']; ?>";		
		}
	else if (x == "Delete") 
		{
		myname=document.forms['frmshow'].elements['DELETE'].value;	
		document.frmshow.action ="deleteadministratorexe.php";
		}
}  	 
</SCRIPT>

deleteadministratorexe.php

<?php
$str;
if (isset($_POST['dtext']))
{
$str = $_POST['dtext'];
echo $str;
}
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Index</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style5 {
	color: #CC0000;
	font-weight: bold;
}
-->
</style>
</head>
<body>
<h1>Welcome <font color="#FF6600"><?php echo $_SESSION['loginname'];?></font></h1>| <a href="logout.php">Logout</a>
<p>This is a password protected area only accessible to members. </p>
<?php
if(isset($_POST['DELETE']))
{
require_once('config.php');
//echo $_POST['dtext'];
$qry = "delete  from tfarmact where ActvID=".$_POST['dtext'];
$result = mysql_query($qry); 
$nr=mysql_affected_rows();
if($nr>0)
{echo "REcord delted";}
else{echo "error";}
}
?>
<p>&nbsp;</p>
</body>
</html>

i have changed query according to my database table and field u have to enter your table name and field.....also include your file which i removed because i haven't those file ....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.