Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Northpole :)
    Posts
    118

    Pretty messed up script..

    I'm trying to make a script where there will be an app to review, and when an admin hit Approved or Denied, it'll Update the Status of the application in the mysql database to either approved or denied and then email the guy his results..But so far it didn't work..below is my script, can anyone fix it?
    PHP Code:
    <?
    session_start
    ();
    require(
    'in/conn.php');
    require(
    'in/resultmail.php');
    require(
    'checklogin.php');
    if(
    $login == 1){
        if(!isset(
    $_GET['id'])){
            
    $query "SELECT ID, Forum_Username, Email FROM app WHERE Status = 0";
            
    $result mysql_query($query) or die("Invalid Query: [$query] " mysql_error());
            
    //display data
            
    echo '<table border="1" cellpadding="2" cellspacing="2" style="border-collapse:collapse" bgcolor="#D5D5D5">'."\n";
            echo 
    '<tr><td colspan="5"><font face="Verdana" size="2">Click on the ID for full details of the application</td></tr>'."\n";
            echo 
    '<tr><font face="Verdana" size="1"><td>ID</td><td>Forum Name</td><td>Email</td></tr>'."\n";
            
    //fetch the items
            
    while($row mysql_fetch_assoc($result)){
                echo 
    '<tr><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$row['ID'].'">'.$row['ID'].'</a></td>'."\n";
                echo 
    '<td>'.$row['Forum_Username'].'</td>'."\n";
                echo 
    '<td>'.$row['Email'].'</td></tr>'."\n";
            }
            echo 
    '</table>';
        }
        if(isset(
    $_GET['id']) && is_numeric($_GET['id'])){
            
    $query "SELECT * FROM app WHERE ID = '".$_GET['id']."' LIMIT 1";
            
    $result mysql_query($query) or die("Invalid Query: [$query] " mysql_error());
            
    //fetch data
            
    $row mysql_fetch_assoc($result);
            
    //displaying data
            
    echo '<table border="1" cellpadding="3" cellspacing="2" style="border-collapse:collapse" bgcolor="#D5D5D5">'."\n";
            while(list(
    $column$value) = each($row)){
                echo 
    '<tr>';
                
    //string processing
                
    if(strpos($column"_") === FALSE){
                    echo 
    '<td>'.$column.'</td>';
                } else {
                    echo 
    '<td>'.str_replace("_"," ",$column).'</td>';
                }
                echo 
    '<td>'.$value.'</td>'."\n";
                echo 
    '</tr>';
            }
            
    ?>
            <form action="<?=$HTTP_SERVER_VARS["PHP_SELF"]?>" method="post">
            <tr><td>Reason if denied (leave this blank if accepted)</td>
            <td><textarea name="reason" cols="40" rows="6" id="reason"></textarea></td></tr>
            <tr><td><input name="accept" type="submit" id="accept" value="Approve">&nbsp;<input name="deny" type="submit" id="deny" value="Deny"></td></tr>
            </form>
            <?
            
    echo '</table>';
            
    $rowid=$row['ID'];
            if(isset(
    $_POST['accept'])){
                
    $query "UPDATE app SET Status = 'Approved' WHERE ID = '$rowid'";
                
    $qq mysql_query($query) or die("Invalid Query: [$query] " mysql_error());
                
    sendAccepted();
            } else if(isset(
    $_POST['deny'])){
                
    $query "UPDATE app SET Status = 'Denied' WHERE ID = '$rowid'";
                
    $qq mysql_query($query) or die("Invalid Query: [$query] " mysql_error());
                
    sendDenied();
            }
        }
    } else if(
    $login != 1){
        echo 
    "You are not logged in, this area is for authorized admins ONLY. Please <a href=\"log.htm\">Login</a>";
    }
    ?>
    Thanks

  2. #2
    Join Date
    Jul 2002
    Location
    Manchester, UK
    Posts
    774
    First off, it would be helpful to know exactly what problems you have actually been having with the script.

    But I can see these problems:

    PHP Code:
    if($login == 1){ 
    What is $login? If it's a session variable then you should be using $_SESSION['login']

    PHP Code:
    if(strpos($column"_") === FALSE){ 
    the "===" should be "=="

    Hope this helps you.

  3. #3
    Join Date
    Feb 2004
    Location
    Northpole :)
    Posts
    118
    the "===" is supposed to be there, also $login is a variable included in the "checklogin.php" file of my.

    what Im struggling in this is..

    IF the application is denied, there will be a field to put in the reason why. And when they hit deny it'll send an email out with that reason.

    Also if you look at the script there are funcstions to get the data out of mysql database, I would like to include some in the email as well.

    I know how to make a mail script, how to make all those. But i don't know how to combine them and all..

    If you examine the script carefully you'll see what I mean.

Posting Permissions

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