+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: [PHP] Variables in PHP

  1. #11
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: [PHP] Variables in PHP

    Quote Originally Posted by sm3xy View Post
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Server Status Page</title>
    </head>
    <body>
    <center>
    <b>Server Status</b><br />
    <img src="rslogo.png" alt="logo" /><br /><br />
    <?php
    if ($_GET['id'] == "register") {
    echo "<form action=\"?id=submit\" method=\"post\">You can only add online servers to this list.<br /><br />Server Name:<br /><input type=\"text\" name=\"name\" /><br />Server IP:<br /><input type=\"text\" name=\"ip\" /><br />Port:<br /><input type=\"text\" name=\"port\" /><br /><br /><input type=\"submit\" value=\"Submit\" /></form><p><br />Click <a href=\"Server_Status.php\">here</a> to go to the main page.<br /></p>";
    } else if($_GET['id'] == "submit") {
    $Server_Name = $_POST['name'];
    $Server_IP = $_POST['ip'];
    $Server_Port = $_POST['port'];
    if (($Server_Name != NULL) && ($Server_IP != NULL) && ($Server_Port != NULL)) {
    $checkReg = @fsockopen("$Server_IP", "$Server_Port", $errno, $errstr, 1);
    if($checkReg) {
    $con = mysql_connect("localhost", "Username", "Password") or die(mysql_error());
    if (!$con) {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("Database") or die(mysql_error());
    mysql_query("INSERT INTO `serverstatus` (`Name`, `IP`, `Port`, `Uptime`, `Total`) VALUES ('$Server_Name', '$Server_IP', '$Server_Port', '1', '1')");
    mysql_close($con);
    echo "<br />Your Server has been successfully added to the list!";
    } else {
    echo "Invalid information or the server is down.<br />";
    }
    } else {
    echo "You did not fill in all of the required information!";
    }
    echo "<p><br />Click <a href=\"Server_Status.php?id=register\">here</a> to add your own server or <a href=\"Server_Status.php\">here</a> to check the list.<br /></p>";
    } else {
    echo "<table><tr><td class=\"header\"><u>Server Name</u></td><td class=\"header\"><u>Server Status</u></td><td class=\"header\"><u>IP Address</u></td><td class=\"header\"><u>Port</u></td><td class=\"header\"><u>Uptime</u></td></tr>";
    $Host = "localhost";
    $User = "Username";
    $Password = "Password";
    $DBName = "Database";
    $Link = mysql_connect ($Host, $User, $Password);
    $Query = "SELECT * from `serverstatus`";
    $Result = mysql_db_query ($DBName, $Query, $Link);
    if ($Result) {
    while ($Row = mysql_fetch_array ($Result)) {
    @mysql_connect($Host, $User, $Password) or die(mysql_error());
    @mysql_select_db ($DBName) or die(mysql_error());
    $checkCurr = @fsockopen("$Row[IP]", "$Row[Port]", $errno, $errstr, 1);
    $total = $Row[Total] + 1;
    echo "<tr><td class=\"lista\">";
    echo "$Row[Name]";
    echo "</td><td class=\"lista\">";
    if($checkCurr) {
    $uptime = $Row[Uptime] + 1;
    echo "<img src=\"online.gif\" alt=\"online\" />";
    $UpdateDB = mysql_query("UPDATE `serverstatus` SET Uptime = $uptime WHERE Uptime = $Row[Uptime]");
    } else {
    echo "<img src=\"offline.gif\" alt=\"offline\" />";
    }
    $UpdateDB2 = mysql_query("UPDATE `serverstatus` SET Total = $total WHERE Total = $Row[Total]");
    echo "</td><td class=\"lista\">";
    echo "$Row[IP]";
    echo "</td><td class=\"lista\">";
    echo "$Row[Port]";
    echo "</td><td class=\"lista\">";
    $accuracy = $uptime/$total;
    if ($accuracy == 1) {
    $accuracy = $accuracy * 100;
    } else {
    $accuracy = 100 - $uptime/$total;
    }
    echo "$accuracy%";
    echo "</td></tr>";
    }
    } else {
    $create = 'CREATE TABLE `serverstatus` (
    `Name` VARCHAR (20) NOT NULL,
    `IP` VARCHAR (50) NOT NULL,
    `Port` VARCHAR (6) NOT NULL,
    `Uptime` VARCHAR (999999) NOT NULL,
    `Total` VARCHAR (999999) NOT NULL,
    PRIMARY KEY (`Name`)
    &nbsp;)';
    mysql_query($create);
    mysql_close();
    }
    echo "</table><p><br />Click <a href=\"Server_Status.php?id=register\">here</a> to add your own server to the above list.<br /></p>";
    }
    ?>
    </center>
    <center>
    <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></p>
    </center>
    </body>
    </html>

    It might be long why dont it work on my site??

    Are you not posting in the wrong section?

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  2. #12
    supajason's Avatar
    supajason is offline x10 Lieutenant supajason is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    England........:-)
    Posts
    288

    Re: [PHP] Variables in PHP

    I see one thing at first look:

    Code:
    $User = "Username";
    $Password = "Password";
    $DBName = "Database";
    you need to fill out your username, password and database to connect to SQL server.
    Last edited by supajason; 11-19-2007 at 01:48 PM.
    supajason was here

  3. #13
    frontl is offline x10Hosting Member frontl is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    29

    Re: [PHP] Variables in PHP

    thank

  4. #14
    satheesh's Avatar
    satheesh is offline x10 Elder satheesh is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Tamil Nadu,India
    Posts
    883

    Re: [PHP] Variables in PHP

    Nice Tutorial.
    I want to buy Some Scripts So Please Click This link:http://affiliate.tufat.com/index.php?id=4384
    Please rate my site:Click here




  5. #15
    sunils's Avatar
    sunils is offline x10 Spammer sunils is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Chennai ,India
    Posts
    2,264

    Re: [PHP] Variables in PHP

    Thanks for the tutorial
    [LEFT][B]Sunil Sankar
    -------------------------------------------------------------------------

  6. #16
    Parsa44 is offline x10 Sophmore Parsa44 is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    232

    Re: [PHP] Variables in PHP

    Very nice tutorial, good job!

+ Reply to Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  3. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  4. [PHP] Placing the Ads in PHP Pages
    By Chris in forum Tutorials
    Replies: 22
    Last Post: 06-04-2005, 11:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers