Home>

When a PHP file is displayed, the text after the PHP sentence is not read.

However, if it is a rental server (star server free plan), everything is properly read and executed.

Why?

Here are the development environments.
OS: Windows 10 Home 64bit
Server: Apache24
PHP: 7.1.2.0
Editor: Brackets

There was a notice that the Star Server PHP was changed to the latest version this year.

Target code

<html>
    <head>
    </head>
    <body>
       <!-Account registration form->
        <form name = "fm" action = "newaccount.php" method = "post">
            <p>This page is not protected. Do not enter personal information.</p>
            <p>ID (required)<input type = "text" name = "id" pattern = "[0-9a-zA-Z] {4,20}" required></p><!- -User ID->
            <p>Name (required)<input type = "text" name = "name" pattern = "[^] +" required></p><!-username->
            <p>Password (required)<input type = "password" name = "pw" pattern = "[0-9a-zA-Z] {4,20}" required></p><!- -Password->
            <p>Password (check) (required)<input type = "password" name = "pw2" pattern = "[0-9a-zA-Z] {4,20}" required></p>&lt ;!-Password (for confirmation)->
            <p>E-Mail (required)<input type = "email" name = "email" required></p><!-Email address->
            <p>Tel<input type = "tel" name = "tel"></p><!-Phone number->
            <p>CreditCard Number<input type = "number" name = "creditnumber"></p><!-Credit number->
            <p>YourName on CreditCard<input type = "text" name = "creditname"></p><!-Card Name->
            <p>Birthday (required)<input type = "date" name = "birthday" required></p><!-Date of birth->
        </form>
        <script type = "text/javascript">
        onload = function () {
            <? php
                $id = $_POST ['id'];
                $pw = $_POST ['pw'];$type = $_POST ['type'];
                $sqllogin = file_get_contents ('../ mysql/mysql.php');
                $sqllogin = substr ($sqllogin, 6, mb_strlen ($sqllogin)-9);
                $sqltxt = explode (",", $sqllogin);
                $link = new mysqli ($sqltxt [0], $sqltxt [1], $sqltxt [2], $sqltxt [3]);
                if ($link->connect_error) echo "Connection failure";
                else {
                    if (strcmp ($type, "new")) {
                        echo "document.fm.style.display = \" block \ ";";
                    } else if (strcmp ($type, "login")) {
                        echo "Login";
                        // Register to DB and go to top page
                    } else {
                        echo "document.write (\" The session is invalid.<br>Please try again.<br><a href = \\\ ".. \\\">Return to top page</a&gt ;\ ");";
                    }
                }
            ?>
        }
        </script>
    </body>
</html>


Since it is still under development and SSL is not included, it is displayed as a reminder that "Please do not enter personal information".

Line 26$sqllogin = substr ($sqllogin, 6, mb_strlen ($sqllogin)-9); and later comments will not generate an error, but the cause is unknown.
The browser validation tool message isFailed to load resource: the server responded with a status of 500 (Internal Server Error).
The contents of mysql.php are as follows, and are assigned to `$sqltxt [0] to [3]&apos ;.

<? php IP address, username, password, database name?>


Originally correct values ​​are entered.
<? php?>does not need to be enclosed, but just in case.

It's for security reasons that the connection to MySQL in the code is messed up.
The mysql folder is set to have a password in the rental server settings, but please let me know if this is not enough.

  • Answer # 1

    I think that you can understand the cause by making the error contents visible.

    <? php
    error_reporting (E_ALL);
    ini_set ('display_errors', 'on');

    I personally commented eitherextension = php_mysqli.dllorextension = php_mbstring.dllin php.ini.