Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. Fourth time with no help, again, I will try to post this.

    Problem: Comments will not delete.
    Situation: Administrative comment deletion. Administrators can delete comments, the comments will not delete.

    Code:
    [code]
    <? include('../header.php'); ?>
    <?php
    if($_COOKIE[admin]){

    $action = $_GET[act];
    $act = $_POST[act];


    if($action == delete){
    $NFin = "SELECT * FROM `news` WHERE `comments` =1";
    $NFgo = mysql_query($NFin);
    $NFnu = mysql_numrows($NFgo);
    if($NFnu == 0){
    echo "No active news";
    }else {
    echo "<table border=0 cellspacing=2 cellpadding=1>";
    echo "<form name=delcomfnews action='".$_SERVER[PHP_SELF]."' method=post>";
    echo "<tr><td colspan=2 align=right><h3>Delete Comments - Step 1</h3>";
    echo "<tr><td>";
    echo "<select name=delcomnews>";
    while ($row1 = mysql_fetch_array($NFgo, MYSQL_BOTH)){
    echo "<option value=$row1[id]>$row1[title]</option>";
    };
    mysql_free_result($NFgo);
    echo "<td><input type=hidden name=act value=dels1><input type=submit value='Show Comments'>";
    echo "</form>";
    echo "</table>";
    };
    }else

    if($act == dels1){
    $NFid = $_POST[delcomnews];
    $NFin = "SELECT * FROM `comments` WHERE newsid ='$NFid'";
    $NFgo = mysql_query($NFin) or die(mysql_error());
    $NFnu = mysql_numrows($NFgo);
    if($NFnu == 0){
    echo "There are no comments for news ID #$NFid";
    }else {
    echo "<table border=0 cellspacing=2 cellpadding=1>";
    echo "<tr><td colspan=2 align=right><h3>Delete Comments - Step 2</h3>";
    while ($row1 = mysql_fetch_array($NFgo, MYSQL_BOTH)){
    echo "<tr><td>Posted by: $row1[poster]<td>($row1[ip])";
    echo "<tr><td colspan=2 align=left>$row1[message]";
    echo "<form name=delcom action='".$_SERVER[PHP_SELF]."' method=post>";
    echo "<input type=hidden name=act value=delcomgo>";
    echo "<tr><td colspan=2 align=right><input type=hidden name=newid value=$NFid><input type=hidden name=comid value=$row1[id]><input type=submit value='Delect Comment #"."$row1[id]"."'>";
    echo "</form>";
    }
    mysql_free_result($NFgo);
    echo "</table>";
    }

    if($act == delcomgo){
    $comid = $_POST[comid];
    $newid = $_POST[newid];
    $DELcom = "DELETE FROM `comments` WHERE id =$comid";
    $DELsql = mysql_query($DELcom) or die(mysql_error());
    $sql1 = "SELECT camount FROM `news` WHERE id =$newid";
    $sql2 = mysql_query($sql1);
    $sql3 = mysql_fetch_assoc($sql2);
    $sql4 = $sql3[camount];
    $sql5 = "$sql4 - 1";
    $sql6 = "UPDATE `news` SET camount ='$sql5' WHERE id=$newid";
    $sql7 = mysql_query($sql6);
    echo "Comment ID #$comid has been deleted!";
    };

    }else if(!$act || !$action){
    echo "<table border=0 cellspacing=3 cellpadding=2>";
    echo "<tr><td colspan=2 align=right><h3>Comment Admin</h3>";
    echo "<tr><td colspan=2 align=left><a href=comments.php?act=edit>Edit Comments</a>";
    echo "<tr><td colspan=2 align=left><a href=comments.php?act=delete>Delete Comments</a>";
    echo "</table>";
    };



    }else {
    echo "Bad auth";
    };
    ?>
    <? require('../footer.php'); ?>
    [/code]
  2. This is about my third time actually trying to get help from these boards for ONE problem.

    I am making a commenting/news system. I have an admin panel which allows the administrator to delete/edit the comments (so far only delete). Well, I have the code appearing to work by looking at it (I think), but when trying to delete the comments, it will just go back to the comment administrative index.

    code:

    [code]
    <?php include('../header.php'); ?>
    <?php
    if($_COOKIE[admin]){

    $action = $_GET[act];
    $act = $_POST[act];


    if($action == delete){
    $NFin = "SELECT * FROM `news` WHERE `comments` =1";
    $NFgo = mysql_query($NFin);
    $NFnu = mysql_numrows($NFgo);
    if($NFnu == 0){
    echo "No active news";
    }else {
    echo "<table border=0 cellspacing=2 cellpadding=1>";
    echo "<form name=delcomfnews action='".$_SERVER[PHP_SELF]."' method=post>";
    echo "<tr><td colspan=2 align=right><h3>Delete Comments - Step 1</h3>";
    echo "<tr><td>";
    echo "<select name=delcomnews>";
    while ($row1 = mysql_fetch_array($NFgo, MYSQL_BOTH)){
    echo "<option value=$row1[id]>$row1[title]</option>";
    };
    mysql_free_result($NFgo);
    echo "<td><input type=hidden name=act value=dels1><input type=submit value='Show Comments'>";
    echo "</form>";
    echo "</table>";
    };
    }else

    if($act == dels1){
    $NFid = $_POST[delcomnews];
    $NFin = "SELECT * FROM `comments` WHERE newsid ='$NFid'";
    $NFgo = mysql_query($NFin) or die(mysql_error());
    $NFnu = mysql_numrows($NFgo);
    if($NFnu == 0){
    echo "There are no comments for news ID #$NFid";
    }else {
    echo "<table border=0 cellspacing=2 cellpadding=1>";
    echo "<tr><td colspan=2 align=right><h3>Delete Comments - Step 2</h3>";
    while ($row1 = mysql_fetch_array($NFgo, MYSQL_BOTH)){
    echo "<tr><td>Posted by: $row1[poster]<td>($row1[ip])";
    echo "<tr><td colspan=2 align=left>$row1[message]";
    echo "<form name=delcom action='".$_SERVER[PHP_SELF]."' method=post>";
    echo "<input type=hidden name=act value=delcomgo>";
    echo "<tr><td colspan=2 align=right><input type=hidden name=newid value=$NFid><input type=hidden name=comid value=$row1[id]><input type=submit value='Delect Comment #"."$row1[id]"."'>";
    echo "</form>";
    }
    mysql_free_result($NFgo);
    echo "</table>";
    }

    if($act == delcomgo){
    $comid = $_POST[comid];
    $newid = $_POST[newid];
    $DELcom = "DELETE FROM `comments` WHERE id =$comid";
    $DELsql = mysql_query($DELcom) or die(mysql_error());
    $sql1 = "SELECT camount FROM `news` WHERE id =$newid";
    $sql2 = mysql_query($sql1);
    $sql3 = mysql_fetch_assoc($sql2);
    $sql4 = $sql3[camount];
    $sql5 = "$sql4 - 1";
    $sql6 = "UPDATE `news` SET camount ='$sql5' WHERE id=$newid";
    $sql7 = mysql_query($sql6);
    echo "Comment ID #$comid has been deleted!";
    };

    }else if(!$act || !$action){
    echo "<table border=0 cellspacing=3 cellpadding=2>";
    echo "<tr><td colspan=2 align=right><h3>Comment Admin</h3>";
    echo "<tr><td colspan=2 align=left><a href=comments.php?act=edit>Edit Comments</a>";
    echo "<tr><td colspan=2 align=left><a href=comments.php?act=delete>Delete Comments</a>";
    echo "</table>";
    };



    }else {
    echo "Bad auth";
    };
    ?>
    <?php require('../footer.php'); ?>
    [/code]
  3. [code]
    function FormCheck()
    {
    $data = mysql_query("SELECT * FROM test WHERE name =$_POST['name']"); 
    $password = $_POST['password'];
    $password_encrypt = md5($password);
    $info = mysql_fetch_array( $data );
    if (empty($_POST['name']))
    {
    echo '<center><font color="red">Please enter your name.<br></font></center>';
    }
    if (empty ($_POST['password']))
    {
    echo '<center><font color="red">Please enter you password.<br></font></center>';
    }
    if (isset($_POST['name'] && $_POST['password'] && $_POST['name'] != $info['name'] || $password_encrypt != $info['password'])
    {
    echo "<center><font color='red'>Sorry your information doesn't match the one that is stored on the database.<br><br></font></center>";
    }else {
    session_start();
    $_SESSION['name'] = $info['name'];
    header ('Location: home.php');
    }
    }
    [/code]

    try that
  4. Well, if you want the search query to be visible in the browser you can use get

    site.com/search.php?search=searched

    vs. POST

    which will post the data and the search query will not be visible

    site.com/search.php
  5. I'm just making a login for my friend using sessions, but I can't seem to get the sessions to register

    [code]
    <?php ob_start();
    <?php
    session_start();


      $sql = "SELECT * FROM account
              WHERE name='$_POST[name]'
              AND pass='$_POST[pass]'";

      $result = mysql_query($sql);
      $num = mysql_num_rows($result);
      if ($num > 0) {
        $id = mysql_fetch_assoc($result);    // ### USER AND PASSWORD ARE CORRECT



        $_SESSION[auth] = "yes";
        $_SESSION[name] = "$_POST[name]";
        $_SESSION[id] = "$id[id]";

        header("Location: ?content=news");

      }else{                                          // ### USER OR PASSWORD IS INCORRECT
        header("Location: ?content=failed");
      }

    ?>
    <?php ob_end_flush(); ?>
    [/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.