need some help with delete record

Discussion in 'PHP' started by dougvcd, Nov 22, 2009.

  1. #1
    need some help for peeps to delete there record from db
    i have a form they enter there email addy and it brings the record on screen
    now i need them to be able to delete it if they want
    here is my code so far
    <?php
    
    include("connectdb.php"); 
    
    $rResult = mysql_query( 
       sprintf(        
       "SELECT * FROM register WHERE email = '%s' LIMIT 1",        
       mysql_real_escape_string($_POST['myemail'])    
       )
       );
       if(1 !== mysql_num_rows($rResult))
       {    
       header('Location: http://www.lostpetsplymouth.com/wrong.php');    
       exit;
       }
    
    $aRecord = mysql_fetch_assoc($rResult);
     printf(    
       '
        
        <strong>Type:</strong>%s<br />    
    	<strong>State:</strong>%s<br />    
    	<strong>Area:</strong>%s<br />    
    	<strong>Description:</strong>%s<br />        
    	 <strong>ID:</strong>%s<br /> 
    	'
    	,
    	$aRecord['type'],    
    	$aRecord['state'],    
    	$aRecord['area'],    
    	$aRecord['desc'],        
    	$aRecord['ID']
    	
     );
    
    
    ?>
    <p> This is your Record Details if you want to Delete press here<p>
    </body>
    PHP:
    cheers
    Doug
     
    dougvcd, Nov 22, 2009 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    on "press here" btn just pass the email or id via $_GET like <a href=del.php?id=$aRec['ID']
    then on del page just do a query like
    "delete from register where ID = $_GET[id]"

    of course, make sure to secure it against mysql injection or other bad things, this is just the idea
     
    crivion, Nov 22, 2009 IP
  3. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for reply
    but as a newbie havnt got a clue
    can any one write this for me
    cheers
    Doug
     
    dougvcd, Nov 22, 2009 IP
  4. uzairjawed

    uzairjawed Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    PM and transfer me the script .. will help you out :)
     
    uzairjawed, Nov 22, 2009 IP