doumi7854
2015-11-10 11:04 阅读 65
已采纳

网页echos php脚本部分

I have recently setup a Fedora 20 VPS with LAMP. My PHP is working properly as you can see from output below: http://talkoot.co.in/info.php

My problem is when I access page below, the php script is printed out instead of being executed. If one 'Views Source' then the entire code is visible. http://talkoot.co.in/WebBackend/admin/login.php

Can someone help me out. Here is the code for login.php:

<?php
include 'init.php';
if(isset($_SESSION['admin'])){
    header('Location: index.php');
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>Login - CPanel</title>
    <link type="text/css" rel="stylesheet" href="libs/css/materialize.min.css"  media="screen,projection"/>
    <link type="text/css" rel="stylesheet" href="libs/css/style.css"  media="screen,projection"/>

</head>
<body>
<div class="container">
    <div class="card publish-form-container">
        <?php
        if(isset($_POST['username'],$_POST['password'])){
            $__USERS->adminLogin($_POST);
        }
        ?>
        <form  class="col s12" method="POST" action="" >

            <div class="input-field">
                <input id="username-field" type="text" name="username">
                <label for="username-field">Username...</label>
            </div>
            <div class="input-field">
                <input id="password-field" type="password" name="password">
                <label for="password-field">Password...</label>
            </div>
            <div>
                <button class="btn waves-effect waves-light pull-right" type="submit">Login
                    <i class="mdi-content-send right"></i>
                </button>
            </div>
        </form>
    </div><!-- Post Card //-->
</div>

<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="libs/js/materialize.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $('.materialboxed').materialbox();
    });
</script>
</body>
</html> 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    duanmi1900 duanmi1900 2015-11-10 11:27

    Your server is not enabled for Short Open Tag there are 2 scenarios

    1. enable it from php.ini short_open_tag = On or using htaccess
    2. Use <?php instead of <?

    P.S: i have shared a link which can explain you why i presented 2 options

    点赞 评论 复制链接分享
  • douzhuiqiu4923 douzhuiqiu4923 2015-11-10 11:14

    As I can see in your phpinfo page:

    short_open_tag  Off Off
    

    that means the short open tag are now allowed

    So, anything you put inside short tags <? ?> won't be parsed as PHP. You'd rather put it inside standard tags <?php ?> block.

    点赞 评论 复制链接分享

相关推荐