Thread: Php help needed
View Single Post
Old 05-10-2008, 03:40 AM   · #2
-NC-
Traveller
 
-NC-'s Avatar
 
Location: In an airport, probably
Trader Rating: (35)
Join Date: Mar 2007
Posts: 1,347
NP$: 573.28 (Donate)
-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of
Animal Cruelty Animal Rescue Ethan Allen Fund Protect Our Planet
Something like this should do the job:
( untested, please back up your database before using )

PHP Code:
<?
ob_start
();

?>
<style>
* {
    font-family: tahoma;
    font-size: 10pt;
    color: #000;
}
</style>
<?php

include("config.php");
$a = $_GET['action'];
$c = $_COOKIE['xxxx'];
$admin_pass = "xxxxxxxxxxxxxxx";
if(
$c!="") {
        print
"<b>Admin</b><p>";
    print
"<a href='admin.php?action=approve'>Approve Links</a><p>";
        print
"<a href='/'>HOME</a><p>";
        if(
$a == "") {
        print
"Please choose a section from above!";
    }
    
    if(
$a == "delete" &&  isset($_GET['id']) )
    {
        
        
$id = $_GET['id'];
        
        if(
is_numeric( $id ) )
        {
            
mysql_query("DELETE FROM `directory` WHERE `id`='$id' LIMIT 1");
        }
        
        
$a = "approve";
    }
    
    if(
$a == "approve") {
        print
"<table border=0 cellpadding=2 cellspacing=0 width=100%>
        <tr>
        <Td>Title</td>
        <td>Category</td>
        <td>URL</td>
        <td>Description</td>
        <td></td>
        </tr>"
;
         
$sql = mysql_query("SELECT * FROM `directory` WHERE `approved`='0'");
        while(
$row = mysql_fetch_array($sql)) {
             
extract($row);
             
             
$sql2 = mysql_query("SELECT * FROM `directory_cats` WHERE `id`='$category'");
             while(
$row2 = mysql_fetch_array($sql2)) {
                  
$category_name = $row2["category"];
             }
                 print
"<tr>
             <td>$headline</td>
             <td>$category_name</td>
             <td>$url</td>
             <td>$description</td>
             <td><a href='admin.php?action=app&id=$id'>Approve</a>&nbsp;|&nbsp;
                 <a href='admin.php?action=delete&id=$id'>Delete</a></td>
             </tr>"
;
        }
            print
"</table>";
    }
    if(
$a == "app") {
            
$id = $_GET['id'];
                if(
$id) {
                 
mysql_query("UPDATE `directory` SET `approved`='1' WHERE `id`='$id'");
                 
Header("Location: admin.php?action=approve");
            }
    }
}
else {
    
$p = $_POST['password'];
        if(
$p!="") {
         if(
$p==$admin_pass) {
              if(
setcookie("xxxx","xxxx",time()+3600)) {
                   
Header("Location: admin.php");
              }
              else {
                   print
"Cant Set Cookie";
              }
         }
         else {
              print
"Wrong Password";
         }
    }
    else {
    
?>
    <form action="admin.php" method="post">
    Type in a password: <input type="password" name="password" size="30"><p>
    <input type="submit" value="Login"></form>
    <?
    
}
}
?>


Please register or log-in into NamePros to hide ads
-NC- is offline  
  Reply With Quote
Site Sponsors
Find out how! YUPPADS http://www.mobisitetrader.com/
Advertise your business at NamePros
All times are GMT -7. The time now is 02:52 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.