Php o anything/将用户重定向到您的登录页面。完美-问题在于“create_excel”文件中的标题位于其他所有标题之下。现在它们位于顶部(就在条件中,非常完美!)这实际上是我最想做的事情(有一个指向文件输出的链接)。我只是做了你提到的,但问题是链接可

Php o anything/将用户重定向到您的登录页面。完美-问题在于“create_excel”文件中的标题位于其他所有标题之下。现在它们位于顶部(就在条件中,非常完美!)这实际上是我最想做的事情(有一个指向文件输出的链接)。我只是做了你提到的,但问题是链接可,php,mysql,html,session,login,Php,Mysql,Html,Session,Login,o anything/将用户重定向到您的登录页面。完美-问题在于“create_excel”文件中的标题位于其他所有标题之下。现在它们位于顶部(就在条件中,非常完美!)这实际上是我最想做的事情(有一个指向文件输出的链接)。我只是做了你提到的,但问题是链接可以共享,任何人都可以访问“create_excel.php”,你可以应用你在logged_in.php页面上使用的相同逻辑。也就是说,检查用户是否已登录(您检查$\u会话['username']是否有效,如果有效,请执行Excel生成代码,否则


o anything/将用户重定向到您的登录页面。完美-问题在于“create_excel”文件中的标题位于其他所有标题之下。现在它们位于顶部(就在条件中,非常完美!)这实际上是我最想做的事情(有一个指向文件输出的链接)。我只是做了你提到的,但问题是链接可以共享,任何人都可以访问“create_excel.php”,你可以应用你在logged_in.php页面上使用的相同逻辑。也就是说,检查用户是否已登录(您检查$\u会话['username']是否有效,如果有效,请执行Excel生成代码,否则,不要执行任何操作/将用户重定向到登录页面。完美-问题是“create\u Excel”文件中的标题位于所有内容的下方。现在它们位于顶部(就在条件中,非常完美!)
Warning: Cannot modify header information - headers already sent by (output started at     /home3/mydir/public_html/d23/members/loggedin.php:6) in     /home3/mydir/public_html/d23/members/create_excel.php on line 92

Warning: Cannot modify header information - headers already sent by (output started at      /home3/mydir/public_html/d23/members/loggedin.php:6) in     /home3/mydir/public_html/d23/members/create_excel on line 93

Warning: Cannot modify header information - headers already sent by (output started at /home3/mydir/public_html/d23/members/loggedin.php:6) in /home3/mydir/public_html/d23/members/create_excel on line 94
ÐÏࡱá;þÿ       þÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
 header('Content-Type: application/vnd.ms-excel');
 header('Content-Disposition: attachment;filename="userList.xls"');
 header('Cache-Control: max-age=0');
<!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=UTF-8" />
<title>Login Please</title>
</head>

<body>

<form action="process_login.php" method="post">
Password: <input type="password" name="password" /><br />
<input type="submit" value="Login" />
</form>

</body>
</html>
mysql_connect($host, $user, $pass);
mysql_select_db($database);


//$username = mysql_real_escape_string($_POST['username']);
$username = "person";
$password = hash('sha512', $_POST['password']);

$result = mysql_query("SELECT * FROM $table WHERE password = '$password'
");


if(mysql_num_rows($result))
{
  // Login
  session_start();
  $_SESSION['username'] = htmlspecialchars($username); // htmlspecialchars() sanitises     XSS
  // Redirect
header('Location: loggedin.php');
exit;
}
else
{
  echo '<p><strong>Error:</strong> Invalid username or password.</p>';
}
?>
<?php 
session_start();
if(isset($_SESSION['username']))
{
  // Logged in
  echo '<p>You are logged in as '. $_SESSION['username']. '.</p>';
   // require the PHPExcel file
require 'create_excel.php';

}
else
{
  // Not logged in
  echo '<p>You are not <a href="login.php">logged in</a>.</p>';
}
?>
<?php
/** Error reporting */
error_reporting(E_ALL);

date_default_timezone_set('Europe/London');

/** PHPExcel */
require_once 'Classes/PHPExcel.php';


// Create new PHPExcel object
$objPHPExcel = new PHPExcel();

// Set properties
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
                             ->setLastModifiedBy("Maarten     Balliauw")
                             ->setTitle("Office 2007 XLSX Test     Document")
                             ->setSubject("Office 2007 XLSX Test     Document")
                             ->setDescription("Test document for         Office 2007 XLSX, generated using PHP classes.")
                             ->setKeywords("office 2007 openxml     php")
                             ->setCategory("Test result file");


// Add some data
$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A1', 'Hello')
            ->setCellValue('B2', 'world!')
            ->setCellValue('C1', 'Hello')
            ->setCellValue('D2', 'world!');

// Miscellaneous glyphs, UTF-8
$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A4', 'Miscellaneous glyphs')
            ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');

// Rename sheet
$objPHPExcel->getActiveSheet()->setTitle('Simple');


// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);


// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="01simple.xls"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
echo '<p>You are logged in as '. $_SESSION['username']. '.</p>';
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="01simple.xls"');
header('Cache-Control: max-age=0');
  echo '<p>You are logged in as '. $_SESSION['username']. '.</p>';
  // require the PHPExcel file
  require 'create_excel.php';
  echo '<p>You are logged in as '. $_SESSION['username']. '.</p>';
   // link to the PXPExcel file
  echo '<a href=\'create_excel.php\'>To Excel!</a>';
  require 'create_excel.php';