Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Admin Notes

  1. #1
    Prick Guest

    Default Admin Notes

    Okay well I'm crap at php and I want to add a admin notes part on my website just like the one on vbulletin

    eg.

    Text box
    _________
    save button

    under it and when you click save it saves it to a .txt file and well as I said like vbulletins admin note thing

  2. #2
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Its pretty easy, if its that small just basically use a text file to load and save.
    PHP Code:
    <html>
    <head>
    <title>Admin Notes</title>
    </head>
    <body>
    <form method="post" action="save.php">
    <?
    ## File DIR (if on your PC C:\adminnotes.txt) or cPanel something like public_html etc.
    $filename "adminnotes.txt";
    ## Open file
    $handle fopen($filename"r");
    ## Contents, we want to echo the contents into the textbox(area)
    $contents fread($handlefilesize($filename));
    ## As this is a small code im including minor HTML
    echo("<textarea name=\"adminnote\">".$contents."</textarea><br>");
    fclose($handle);
    ?>
    <input type="submit" value="Save admin notes"><br></form>
    </body>
    </html>
    - This file is called "adminnotes.php"


    example = http://www.driftpanzy.co.uk/admin.php
    PHP Code:
    <?
    $filename 
    "adminnotes.txt";
    if(isset(
    $_POST["adminnote"])) {
        if((
    $_POST["adminnote"] == "")) {
            echo(
    "No content");
            } else {
                
    $content $_POST["adminnote"];
                if(
    is_writable($filename)) {
                    if(!
    $handle fopen($filename'a')) {
                        echo(
    "Cant write");
                        exit;
                        } else {
                        echo(
    "Success, updated");
                        
    fclose($handle); exit;
                        }
                        echo(
    "File name isn't writable");
    }
    }
    }
    ?>
    This was done quickly so I haven't really checked for errors/exploits.
    Hi, names James. I am a web developer.

  3. #3
    Prick Guest

    Default

    just one.. save.php should be adminnotes.php on line six of the first code

    And thanks

    Also how can I ahve it so it just reloads the page instead of showing "Success Updated"?
    Last edited by Prick; 10-03-2008 at 04:17 PM.

  4. #4
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    The bottom PHP is under the page "send.php", sorry I didn't tell you that lol, to read load the page you could just include("adminnotes.php"); or do a meta reload.
    Hi, names James. I am a web developer.

  5. #5
    Prick Guest

    Default

    Okay one more thing to add..

    I was thinking this might not be secure and can be easily viewed/or edited by someone I don't want to edit it, so maybe it could be safer in a table in my sites database?

    If it is safer (probably is) can anyone edit that code so that it writes to a database table and then prints the text back into the textarea

    EDIT: sorry for all the questions but I'm getting

    Warning
    : fread() [function.fread]: Length parameter must be greater than 0 in /home/virtualg/public_html/site/admin/adminnotes.php on line 13
    when I load the page
    Last edited by Prick; 10-03-2008 at 04:36 PM.

  6. #6
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    You can make it save it to a MYSQL table, but you could always just use the permissions of the folder from 755 to something else so other users can read it, only the system. Having a table JUST for a "online notepad" isn't really worth it, unless your using it to process passwords etc, for people not to be able to add to it, add it to your "Members system" or use cPanel little nifty password directories.
    Hi, names James. I am a web developer.

  7. #7
    Prick Guest

    Default

    Okay I still need help on the fread error :/

  8. #8
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Thats because the file has no content in it, it cant read from nothing.
    Hi, names James. I am a web developer.

  9. #9
    Prick Guest

    Default

    Ugh nothing ever works for me :eusa_wall

    In my /site/admin I've got

    adminnotes.php with your code in it
    save.php with your code in it
    adminnotes.txt with a small bit of text in it

    I've set all permissions on each file to 755

    I've Added an include('adminnotes.php'); into the admin panel of my website

    I've put some text in it and clicked save admin note and it doesn't save it

  10. #10
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    755 allows all settings I think lol - edit = I didnt put write to file LOL sorry man let me paste the code for send.php. (replace)

    PHP Code:
    <?
    $filename 
    "adminnotes.txt";
    if(isset(
    $_POST["adminnote"])) {
        if((
    $_POST["adminnote"] == "")) {
            echo(
    "No content");
            } else {
                
    $content $_POST["adminnote"];
                if(
    is_writable($filename)) {
                    if(!
    $handle fopen($filename'w')) {
                        echo(
    "Cant write");
                        exit;
                        } else {
                        if (
    fwrite($handle$content) === FALSE) {
                            echo(
    "File name isn't writable");
                            }
                            else
                            {
                            
    ## add here to redirect
                            
    echo("Success...");
                            }
                        }
    }
    }
    }
    fclose($handle);
    ?>
    Last edited by Protege; 10-03-2008 at 08:17 PM. Reason: My reason for being wrong was: IT WAS IN THE MORNING!
    Hi, names James. I am a web developer.

Page 1 of 2 12 LastLast

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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