简体   繁体   中英

PHP Page Not Displaying Correctly

I've coded a form for a hiring application on an online game, but am running some issues when I actually put the code on the website. Running this on my local apache web server runs fine, but doing this on a LiteSpeed web server online seems to not work. Is there anything invalid in the code?

I've set the code already to detect any errors (I've removed that from the below sample), but nothing turns up except for undefined variables (which is fine in this case).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Zone Application Manager</title>
</head>
<body>
<?php
require("includes.php");
  function displayElements($category) {
    echo "<div id=\"left\">\n";
    $col1 = mysql_query("SELECT * FROM gp_applications WHERE category = '$category' ORDER BY id ASC");
    echo "<h3>" . $category . "</h3>\n";
    echo "<form action=\"#\" method=\"get\">\n";
    echo "<select name=\"category\">\n";
    if ($category=="Unread Apps") {
      echo "<option value=\"Unread Apps\" selected=\"selected\">Unread Apps</option>\n";
      echo "<option value=\"Deleted Apps\">Deleted Apps</option>\n";
      echo "<option value=\"Good Apps\">Good Apps</option>\n";
    }
    if ($category=="Deleted Apps") {
      echo "<option value=\"Unread Apps\">Unread Apps</option>\n";
      echo "<option value=\"Deleted Apps\" selected=\"selected\">Deleted Apps</option>\n";
      echo "<option value=\"Good Apps\">Good Apps</option>\n";
    }
    if ($category=="Good Apps") {
      echo "<option value=\"Unread Apps\">Unread Apps</option>\n";
      echo "<option value=\"Deleted Apps\">Deleted Apps</option>\n";
      echo "<option value=\"Good Apps\" selected=\"selected\">Good Apps</option>\n";
    }
    echo "</select>\n";
    echo "<input type=\"submit\" value=\"Choose\">\n";
    echo "</form>\n";
    echo "<br />\n";
    echo "<form action=\"#\" method=\"get\">\n";
    echo "<input type=\"hidden\" name=\"category\" value=\"" . $category . "\">\n";
    echo "<select name=\"id\" size=\"25\">\n";
    while($row1 = mysql_fetch_array($col1)) {
      echo "<option value=\"" . $row1[id] . "\">" . $row1[q2] . "</option>\n";
    }
    echo "</select>\n";
    echo "<br />\n";
    echo "<br />\n";
    echo "<input type=\"submit\" name=\"read\" value=\"Read Application\">\n";
    echo "<br />\n";
    echo "<input type=\"submit\" name=\"delete\" value=\"Delete Application\">\n";
    echo "<br />\n";
    echo "<input type=\"submit\" name=\"unread\" value=\"Mark Application Unread\">\n";
    echo "<br />\n";
    echo "<input type=\"submit\" name=\"good\" value=\"Good Application\">\n";
    echo "</div>\n";
    echo "</form>";
    echo "<form action=\"#\" method=\"get\">\n";
    echo "<div id=\"bottom\">\n";
    echo "<select name=\"appMode\">";
    $mode = file_get_contents('mode.txt');
    if($mode=="yes") {
    echo "<option value=\"appon\" selected=\"selected\">Turn Application On</option>";
    echo "<option value=\"appoff\">Turn Application Off</option>";
    } else {
    echo "<option value=\"appon\">Turn Application On</option>";
    echo "<option value=\"appoff\" selected=\"selected\">Turn Application Off</option>";
    }
    echo "</select>";
    echo "<input type=\"submit\" name=\"appModeBtn\" value=\"Toggle App Mode\">";
    echo "</div>";
    echo "</form>";
  }
  function executeAppAction($id) {
  if (isset($_GET['good'])) {
      mysql_query("UPDATE gp_applications SET category='Good Apps' WHERE id='$id'")or die(mysql_error());
      header("Location: admin.php?action=admin");
    }
  if (isset($_GET['unread'])) {
      mysql_query("UPDATE gp_applications SET category='Unread Apps' WHERE id='$id'")or die(mysql_error());
      header("Location: admin.php");
    }
    if (isset($_GET['delete'])) {
      mysql_query("UPDATE gp_applications SET category='Deleted Apps' WHERE id='$id'")or die(mysql_error());
      header("Location: admin.php");
    }
    if (isset($_GET['read'])) {
    $result = mysql_query("SELECT * FROM gp_applications WHERE id='$id'");
    if ($result) {
        $row = mysql_fetch_assoc($result);
    }
    echo "<div id=\"formBody\">";
    //application opener, not needed to view
    echo "</div>\n";
  }
  }
    if($_POST['pwd'] || isset($_COOKIE['zonegp_application_login'])) {
      if($_POST['pwd']=="xxxx") {
        $hour = time() + 3600;
        $pwd = $_POST['pwd'];
        setcookie('zonegp_application_login', $pwd, $hour);
      }
      if($_COOKIE['zonegp_application_login']=="xxxx" || $_POST['pwd']=="xxxx") {
        echo "<h1>The Doctor's Application Manager</h1>\n";
        echo "<p><a href=\"logout.php\">Logout</a></p>\n";
        if($_GET['category']) {
        $appcategory = $_GET['category'];
        }
        if(empty($appcategory)) {
          $appcategory = "Unread Apps";
          displayElements($appcategory);
        }
        else {
          displayElements($appcategory);
        }
        if($_GET['id']) {
          $id = $_GET['id'];
          executeAppAction($id);
        }
        if ($_GET['appModeBtn']) {
          if($_GET['appMode']=="appon") {
            $myFile = "mode.txt";
            $fh = fopen($myFile, 'w') or die("can't open file");
            $stringData = "yes";
            fwrite($fh, $stringData);
            fclose($fh);
            header("Location: admin.php");
          }
          if($_GET['appMode']=="appoff") {      
            $myFile = "mode.txt";
            $fh = fopen($myFile, 'w') or die("can't open file");
            $stringData = "no";
            fwrite($fh, $stringData);
            fclose($fh);
            header("Location: admin.php");
          }
        }
      }
      else {
        echo "Incorrect Password";
      }
    }
    else {
      header("Location: login.html");
    }
?>
</body>
</html>

Hosted Locally: https://dl.dropboxusercontent.com/u/63673315/sopic1.png Hosted Online: https://dl.dropboxusercontent.com/u/63673315/sopic2.png

Yes, I am running PHP on the website version.

please add

var_dump(file_exists('includes.php'));

just before

require('includes.php');

require drops any further code if the file is not found

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM