Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
I have a table which contains fname,lname and email addres and dynamically added check box field too.
Once i checked the check box and then press delete button the relevent record should be deleted.
I tried as follows.
<?php
if(isset($_POST['deleteAcc']))//delete button
{
      $getEmail = "SELECT * FROM user";
      $getEmailResult = mysql_query($getEmail);
      while($r = mysql_fetch_array($getEmailResult))
      {
       $email = $r['email'];
       if(isset($_POST[$email])!=NULL)//check box
       {
           $deleteUserQuery = "DELETE FROM user WHERE email='$email'";
           $deleteUserQueryResult = mysql_query($deleteUserQuery);
           header('Location:admin.php');
       }
      }
}
?>


above code will properly work when email something like 'abc'.but it does not work when email like 'a@b.c'.

help me!
thank you.
Posted
Updated 3-Mar-10 23:04pm
v2

hello friend,
i guess did you make validation at your text box ... if yes than clear it..
if its not solving your problem then let me know what is given your error.. use Try Catch for this particular code... than will show you error in massage box...

reply me if its fine or not....
 
Share this answer
 
It looks like you're using the email address as the input name. PHP rewrites '.' in an input name to '_', so instead of $_POST['a@b.c'] the option will be $_POST['a@b_c'].

Try this instead:
...
if(isset($_POST[str_replace('.','_',$email)])!=NULL) //check box
...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900