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!


Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default Site Status Page.

    My first ever peice of PHP coding. Please be constructive when criticising it

    Sorry I didn't really know where this is supposed to go. If it's in the wrong place can a Mod move it?

    Page: index.php
    PHP Code:
    <?php

    $sitestat 
    "off"//Change this to on or off. NOTE: Chaning it to something other than on or off will result in the user not being able to access the site, even if it's on!

    if ($sitestat == "off") {
    echo 
    "<font color=\"Red\" size=\"3\" face=\"Verdana\">Site Offline!</font>"// Only bit you need to edit.
    } elseif ($sitestat == "on") {
    echo 
    "<font color=\"Green\" size=\"3\" face=\"Verdana\">Site Online. 
    <META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=main.php\"></font>"
    // Only bit you need to edit.
    } else {
    echo 
    "Sorry, your admin didn't set the status for the website... The valid statuses are <b>off</b> and <b>on</b>.";
    }
    //------------------------------------------------------------------------------------//
    // Edit what I told you not to edit (if you don't know PHP). The script may not work! //
    //------------------------------------------------------------------------------------//

    ?>
    Last edited by lolwut; 25-03-2007 at 09:05 AM. Reason: Updated to make more practical
    i've been here for over 8 years and i don't know why

  2. #2
    Join Date
    Nov 2006
    Location
    Leeds, Yorkshire
    Posts
    992
    Tokens
    0

    Default

    Wow nice coding for a first.
    Maybe you could find some other ways of doing re-directs.


  3. #3
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    Tyvm

    I will do more as I learn more PHP... I was working on a password preotected page to change the status, but it didn't work right. As I'd need MySQL and tbh I cba with it.
    Last edited by lolwut; 25-03-2007 at 10:37 AM.
    i've been here for over 8 years and i don't know why

  4. #4
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    3,285
    Tokens
    0

    Latest Awards:

    Default

    Here's the code for a redirect:

    PHP Code:
    <?php
    header
    ("Location: where to do");
    ?>



    i used to be NintendoNews. visit my blog or add me on twitter.
    need help with vista? i am a microsoft certified technology specialist in configuring windows vista and connected home integrator.. pm me for help!


    "I am the way, the truth, and the life. No one comes to the Father except through me"
    John 14:6 (NIV)


  5. #5
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    Ty.

    VERSION 2:
    PHP Code:
    <?php

    $sitestat 
    "off"//Change this to on or off. NOTE: Chaning it to something other than on or off will result in the user not being able to access the site, even if it's on!

    if ($sitestat == "off") {
    echo 
    "<font color=\"Red\" size=\"3\" face=\"Verdana\">Site Offline!</font>"// Only bit you need to edit.
    } elseif ($sitestat == "on") {
    echo 
    "<font color=\"Green\" size=\"3\" face=\"Verdana\">Site Online.
    header("
    Locationpage.php"); 
    </font>"
    // Only bit you need to edit.
    } else {
    echo 
    "Sorry, your admin didn't set the status for the website... The valid statuses are <b>off</b> and <b>on</b>.";
    }
    //------------------------------------------------------------------------------------//
    // Edit what I told you not to edit (if you don't know PHP). The script may not work! //
    //------------------------------------------------------------------------------------//

    ?>
    If a mod can merge this with the original post I'd be greafull ;]
    i've been here for over 8 years and i don't know why

  6. #6
    Join Date
    Mar 2007
    Location
    Earth, sometimes...
    Posts
    136
    Tokens
    0

    Default

    echo "<font color=\"Green\" size=\"3\" face=\"Verdana\">Site Online.
    header("Locationpage.php");
    </font>"; // Only bit you need to edit.
    } else {

    You forgot to add the back slashes in front of the quotes. Pretty good for a first. I'm learning PHP too.
    I like a good nap. Sometimes its the only thing getting me up in the morning.


    Selling (un)coded templates, PM me for info


  7. #7
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Nope your advice is wrong.

    Remove the: header(""); from the echo. It shouldnt be there.

  8. #8
    Join Date
    Jul 2006
    Location
    Athens
    Posts
    842
    Tokens
    0

    Default

    Would be better with an input field and a databse but good for a first attempt


  9. #9
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    Quote Originally Posted by Drompo View Post
    Would be better with an input field and a databse but good for a first attempt
    Yeah I tryed but everything broke.
    i've been here for over 8 years and i don't know why

Posting Permissions

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