Help with [get]

Discussion in 'PHP' started by Dirty-Rockstar, Jul 14, 2007.

  1. #1
    From view_profile.php
    
    <form name="delete" method="get" action="modpanel.php">
    <input type="hidden" name="id" value="<?= $rows['id'] ?>">
    <input type="hidden" name="postsdump" value="1">
    <input type="submit" name="Submit" value="Delete" class="button"> Deletes the users  posts
    </form>
    
    HTML:
    modpanel.php

    
    <?php
    require('config.php');
    if(!in_array($_SESSION['username'],$admin_users))
    die('You do not have permission to delete users.');
    // get value of id that sent from address bar
    $id=mysql_real_escape_string($_GET['id']);
    $sql="SELECT * FROM {$db_prefix}user WHERE id='$id'";
    $rows=mysql_fetch_array(mysql_query($sql));
    if(in_array($name,$admin_users))
    die('You cannot delete yourself');
    if (!$rows)
    die("This user does not exist.");
    $name=$rows['username'];
    
    if($_GET['postsdump']) {
    $sql = "DELETE FROM {$db_prefix}question WHERE name='$name'";
    $result2=mysql_query($sql)or die(mysql_error());
    
    
    $sql = "SELECT * FROM {$db_prefix}answer WHERE a_name='$name'";
    $result3=mysql_query($sql) or die(mysql_error());
    
    while($rows=mysql_fetch_array($result3)) {
    $sql = "DELETE FROM {$db_prefix}answer WHERE a_id='".$rows['a_id']."' AND question_id='".$rows['question_id']."'";
    $result=mysql_query($sql) or die(mysql_error());
    
    
    $sql = "UPDATE {$db_prefix}question SET reply=reply-1 WHERE id='".$rows['question_id']."'";
    $result2=mysql_query($sql) or die(mysql_error());
    
    }
    
    } else {
    $result2 = 1;
    $result3 = 1;
    }
    
    
    if($result && $result2 && $result3){
    header("Location: members.php");
    }
    
    else {
    echo "ERROR";
    }
    ?>
    
    PHP:
    Im getting the word "ERROR" so im guessing its not getting postsdump


    help? :p

    edit: I took out the second result2 and replaced it with result4 and changed the code accordingly. didnt fix it. so i set it back waiting on a reply :p
     
    Dirty-Rockstar, Jul 14, 2007 IP
  2. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #2
    try using isset() with it. if ( isset($_GET['postsdump']) )
     
    ansi, Jul 14, 2007 IP
  3. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Tired it, same error.
     
    Dirty-Rockstar, Jul 14, 2007 IP
  4. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    it prints the var. so its not get. its the if itself.

    darnit -_-

    ill rebuild it
     
    Dirty-Rockstar, Jul 14, 2007 IP