Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts

    cant edit or delete posts

    here is my code

    Code:

    PHP Code:
    <?php 
          $topicid
    =$_GET['id']; 
    if (isset(
    $_POST['edit'])) { 
                  if (
    $_POST['deletepost'] == 'deletepost'){ 
            
    $threadid =  mysql_real_escape_string$_POST['id']); 
            
    mysql_query("DELETE FROM forumtutorial_posts WHERE postid='$threadid'")  
    or die(
    mysql_error()); 
    mysql_query("UPDATE `forumtutorial_posts` SET `numreplies`=`numreplies`-'1' WHERE `postid`='$topicid'")  
    or die(
    mysql_error());  
    header"refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id");   
        } else { 
      
    //    $threadid =  mysql_real_escape_string( $_POST['id']);
        
    $threadid =  $CONT_ID;
        
    $message $_POST['message']; 
        echo 
    $message;  
         
    $query "UPDATE forumtutorial_posts SET  post = '$message' WHERE postid='$threadid' "
        
    mysql_query($query) or die('Error, query failed'); 
        
    header"refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id");   
         




         


    }else{ 


    ?> 

    <script src="../../css/SpryCollapsiblePanel.js" type="text/javascript"></script> 
          <link href="http://www.runningprofiles.com/css/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" /> 
          <div id="CollapsiblePanel<?PHP 
           
    // I had to add $CONT_ID that is set in the script that includes this. and ive done it again for the "tabindex" just to ensure it works!
          
    echo $CONT_ID?>" class="CollapsiblePanel"> 
      <div class="CollapsiblePanelTab" tabindex="<?PHP echo $CONT_ID?>"> Edit</div> 
      <div class="CollapsiblePanelContent"> 
    <form name='input' action='index.php?page=message&forum=general&id=<? echo $id ?>' method='post'> 
        <input type="hidden" name="id" value="<?php echo $getreplies3['postid'?>"> 
        <div align="center"> 
          <label> 
          <textarea class='inputforum' name="message" id="message" cols="500" rows="5"><? echo $message?></textarea> 
          </label> 
                <input type="checkbox" name="deletepost" value="deletepost" /> 
         delete post<br/> 
          <br/> 
           
           
            <input type='submit' name='edit' class="submit-btn"  value=''/> 
      </div> 
    </form>      <? 

    ?></div> 
    </div> 


     <script type="text/javascript"> 
    <!-- 
    <?PHP
    //Ive added the variable $CONT_ID here aswell. THIS IS REQUIRED FOR THE
    //JS to work!
    ?>
    var CollapsiblePanel<?PHP echo $CONT_ID?> = new Spry.Widget.CollapsiblePanel("CollapsiblePanel<?PHP echo $CONT_ID?>", {contentIsOpen:false}); 
    //--> 
          </script>
    for some reason the posts wont delete or edit but if i hit delete it till -1 off the postcount

    any1 have any reason why?

  • #2
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I hope this scripts will help

    <?php
    $topicid=$_GET['id'];
    if (isset($_POST['deletepost'])) {
    mysql_query("DELETE FROM forumtutorial_posts WHERE postid='$topicid'")
    or die(mysql_error());
    mysql_query("UPDATE `forumtutorial_category` SET `numreplies`=`numreplies`-'1' WHERE `forum`='general'")
    or die(mysql_error());
    header("location:http://www.runningprofiles.com/members/index.php?page=message&forum=general");
    }


    if (isset($_POST['edit'])) {
    $message = $_POST['message'];
    echo $message;
    $query = "UPDATE forumtutorial_posts SET post = '$message' WHERE postid='$topicid' ";
    mysql_query($query) or die('Error, query failed');
    header("location:http://www.runningprofiles.com/members/index.php?page=message&forum=general");

    }


    ?>


    No Need to }else{ ..... html

    But I am confusing about the second mysql database

    ..mysql_query("UPDATE `forumtutorial_posts` SET `numreplies`=`numreplies`-'1' WHERE `postid`='$topicid'")

    I you like to delete post message you need to reduce category post or whatever your database name.
    and no need to add ...general&id=$id");
    at your header link


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •