我试图登录系统,但是我的一页工作而不是另一页,请帮忙!
这是它工作的第一页
<?php
/* Displays user information and some useful messages */
session_start();
// Check if user is logged in using the session variable
if ( $_SESSION['logged_in'] != 1 ) {
$_SESSION['message'] = "You must log in before viewing your profile page!";
header("location: error.php");
}
else {
// Makes it easier to read
$first_name = $_SESSION['first_name'];
$last_name = $_SESSION['last_name'];
$email = $_SESSION['email'];
$active = $_SESSION['active'];
}
?>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Welcome <?= $first_name.' '.$last_name ?></title>
<?php include 'css/css.html'; ?>
</head>
<body>
<div class="form">
<h1>Welcome</h1>
<p>
<?php
// Display message about account verification link only once
if ( isset($_SESSION['message']) )
{
echo $_SESSION['message'];
// Don't annoy the user with more messages upon page refresh
unset( $_SESSION['message'] );
}
?>
</p>
<?php
// Keep reminding the user this account is not active, until they
activate
if ( !$active ){
echo
'<div class="info">
Account is unverified, please confirm your email by clicking
on the email link!
</div>';
}
?>
<h2><?php echo $first_name.' '.$last_name; ?></h2>
<p><?= $email ?></p>
<a href="logout.php"><button class="button button-block"
name="logout"/>Log Out</button></a>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
在此页面中,其中显示:
<title>Welcome <?= $first_name.' '.$last_name ?></title>
正在工作并说欢迎和用户的名字。
但是在这个页面中:
<?php
session_start();
// any HTML input *must* be HTML-escaped to prevent the user from injecting
malicious JavaScript code
function html_escape($raw_input, $encoding)
{
return htmlspecialchars($raw_input, ENT_QUOTES | ENT_SUBSTITUTE, $encoding);
}
/* Displays user information and some useful messages */
if ($_SESSION['logged_in'] != 1) {
$first_name = 'Guest, Please Login or Sign Up to Play!';
$last_name = '';
}
else {
// Makes it easier to read
$first_name = $_SESSION['first_name'];
$last_name = $_SESSION['last_name'];
}
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>CashBallz</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--[if lte IE 8]><script src="assets/js/ie/html5shiv.js"></script><!
[endif]-->
<link rel="stylesheet" href="assets/css/main.css" />
<!--[if lte IE 9]><link rel="stylesheet" href="assets/css/ie9.css" /><!
[endif]-->
<!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie8.css" /><!
[endif]-->
</head>
<body class="landing">
<div id="page-wrapper">
<!-- Header -->
<header id="header">
<h1 id="logo"><a href="index.php">CashBallz</a></h1>
<nav id="nav">
<ul>
<li><a href="index.php">Home</a></li>
<li>
<a href="#">Play</a>
<ul>
<li><a href="left-sidebar.php">Server 1</a>
</li>
<li><a href="right-sidebar.php">Server 2</a>
</li>
<li><a href="no-sidebar.php">Server 3</a>
</li>
</ul>
</li>
<li><a href="elements.php">Paypal</a></li>
<li><a href="loginsystem/loginpage.php"
class="button special">Sign Up/Login</a></li>
</ul>
</nav>
<br>
<p style="float:right; font-size: 30px" >
Welcome <?php= $first_name.' '.$last_name ?>
</p>
</header>
<!-- Banner -->
<section id="banner">
<div class="content">
<header>
<h2>CashBallz</h2>
<p>The best way to make money by having fun.</p>
</header>
<span class="image"><img src="images/pic01.jpg" alt=""
/></span>
</div>
<a href="#one" class="goto-next scrolly">Next</a>
</section>
<!-- Explain -->
<section id="one" class="spotlight style1 bottom">
<span class="image fit main"><img src="images/pic02.jpg"
alt="" /></span>
<div class="content">
<div class="container">
<div class="row">
<div class="4u 12u$(medium)">
<header>
<h2>The Game</h2>
<p>CashBallz was made by two students to
help people gain easy money by having fun!</p>
</header>
</div>
<div class="4u 12u$(medium)">
<p>We had trouble finding ways to make money
because we werent old enough to get a job. So we decided to create a fun way
to
make money for ourselves and other people!</p>
</div>
<div class="4u$ 12u$(medium)">
<p>We hope you enjoy our game as much as we
did creating it.</p>
</div>
</div>
</div>
</div>
<a href="#two" class="goto-next scrolly">Next</a>
</section>
<!-- How to start playing -->
<section id="two" class="spotlight style2 right">
<span class="image fit main"><img src="images/pic03.jpg"
alt="" /></span>
<div class="content">
<header>
<h2>How to start playing!</h2>
<p>First, press sign up. You will be directed to a
page where you have to create an account with your paypal.</p>
</header>
<p>Log in with your paypal with our secure servers.
Then, press any server with the most people, and start playing!</p>
<ul class="actions">
<li><a href="loginsystem/loginpage.php"
class="button">Sign Up</a></li>
</ul>
</div>
<a href="#three" class="goto-next scrolly">Next</a>
</section>
<!-- How to play the game -->
<section id="three" class="spotlight style3 left">
<span class="image fit main bottom"><img
src="images/pic04.jpg" alt="" /></span>
<div class="content">
<header>
<h2>How to play the game / controls</h2>
<p>Use WASD or the arrow keys to move around.<p>
<p>Press space to split, and press shift to let out
a one-cent blob.<p>
</header>
<p>This game is similiar to Agar.io, eat another player
to gain their mass and price. Eat the small blobs to gain mass, but no
money.
</p>
<p>Press "C" to cash out, it will take 10 seconds of non
movement to leave the game with all your money.<p>
<ul class="actions">
<li><a href="#" class="button">Control Page</a></li>
</ul>
</div>
<a href="#four" class="goto-next scrolly">Next</a>
</section>
<!-- Strategies -->
<section id="four" class="wrapper style1 special fade-up">
<div class="container">
<header class="major">
<h2>Strategies to win!</h2>
<p>There are many ways to beat other players and
gain money faster!</p>
</header>
<div class="box alt">
<div class="row uniform">
<section class="4u 6u(medium) 12u$(xsmall)">
<span class="icon alt major fa-area-chart">
</span>
<h3>Split!</h3>
<p>Split to catch other blobs that are less
than 1/2 your size!</p>
</section>
<section class="4u 6u$(medium) 12u$(xsmall)">
<span class="icon alt major fa-comment">
</span>
<h3>Eleifend lorem ornare</h3>
<p>Feugiat accumsan lorem eu ac lorem amet
accumsan donec. Blandit orci porttitor.</p>
</section>
<section class="4u$ 6u(medium) 12u$(xsmall)">
<span class="icon alt major fa-flask">
</span>
<h3>Cubilia cep lobortis</h3>
<p>Feugiat accumsan lorem eu ac lorem amet
accumsan donec. Blandit orci porttitor.</p>
</section>
<section class="4u 6u$(medium) 12u$(xsmall)">
<span class="icon alt major fa-paper-plane">
</span>
<h3>Non semper interdum</h3>
<p>Feugiat accumsan lorem eu ac lorem amet
accumsan donec. Blandit orci porttitor.</p>
</section>
<section class="4u 6u(medium) 12u$(xsmall)">
<span class="icon alt major fa-file"></span>
<h3>Odio laoreet accumsan</h3>
<p>Feugiat accumsan lorem eu ac lorem amet
accumsan donec. Blandit orci porttitor.</p>
</section>
<section class="4u$ 6u$(medium) 12u$(xsmall)">
<span class="icon alt major fa-lock"></span>
<h3>Massa arcu accumsan</h3>
<p>Feugiat accumsan lorem eu ac lorem amet
accumsan donec. Blandit orci porttitor.</p>
</section>
</div>
</div>
<footer class="major">
<ul class="actions">
<li><a href="#" class="button">Magna sed
feugiat</a></li>
</ul>
</footer>
</div>
</section>
<!-- How you're making money -->
<section id="five" class="wrapper style2 special fade">
<div class="container">
<header>
<h2>Sign Up</h2>
<p>Start playing today!</p>
</header>
<form method="post" action="#" class="container 50%">
<div class="row uniform 50%">
<div class="8u 12u$(xsmall)"><input type="email"
name="email" id="email" placeholder="Your Email Address" /></div>
<div class="4u$ 12u$(xsmall)"><input
type="submit" value="Get Started" class="fit special" /></div>
</div>
</form>
</div>
</section>
<!-- Footer -->
<footer id="footer">
<ul class="icons">
<li><a href="#" class="icon alt fa-twitter"><span
class="label">Twitter</span></a></li>
<li><a href="#" class="icon alt fa-facebook"><span
class="label">Facebook</span></a></li>
<li><a href="#" class="icon alt fa-instagram"><span
class="label">Instagram</span></a></li>
<li><a href="#" class="icon alt fa-envelope"><span
class="label">Email</span></a></li>
</ul>
<ul class="copyright">
<li>© Untitled. All rights reserved.</li>
<li>Creator: <a href="http://html5up.net">CashBallz.Co</a></li>
</ul>
</footer>
</div>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.scrolly.min.js"></script>
<script src="assets/js/jquery.dropotron.min.js"></script>
<script src="assets/js/jquery.scrollex.min.js"></script>
<script src="assets/js/skel.min.js"></script>
<script src="assets/js/util.js"></script>
<!--[if lte IE 8]><script src="assets/js/ie/respond.min.js">
</script><![endif]-->
<script src="assets/js/main.js"></script>
</body>
</html>
当它说出来时,它没有说出用户名或姓氏,甚至是客人留言:
Welcome <?php= $first_name.' '.$last_name ?>
我将变量设置为相同的两倍,我不明白什么是错的 我不知道这是否有用,但这两个页面位于不同的文件夹中,并且所有会话和数据库php文件都在第一页的文件夹中,但我不知道是否重要。
谢谢!
答案 0 :(得分:1)
您需要该行说:
Welcome <?php echo $first_name.' '.$last_name ?>
我不确定&lt;?=?&gt;你正在使用的符号,但我想这与它有关。你的第二个是&lt;?php =而不是&lt;?=这可能没有达到预期效果。如果您有兴趣阅读更多有关它们的信息,我认为这些被称为php short tags。
答案 1 :(得分:0)
您使用<?=$var?>
或<?php echo $var;?>
所以将问题行更改为此
<p style="float:right; font-size: 30px" >
Welcome <?= $first_name.' '.$last_name?>
</p>
OR
<p style="float:right; font-size: 30px" >
Welcome <?php echo $first_name .' '. $last_name;?>
</p>