Zubrag.com
April 23, 2018, 08:35:15 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Warning: Cannot modify header information  (Read 9633 times)
abssom
Newbie
*
Posts: 3


« on: October 17, 2007, 06:51:02 AM »

Thanks to Zubra for the password protect script.

Im on the verge of getting password protect working on my website, except for the fact that it comes up with the following message:

Warning: Cannot modify header information - headers already sent by (output started at /home/ahdiorg/public_html/members_area.php:1) in /home/ahdiorg/public_html/pass_protect/ahdi_password_protect.php on line 138

even though i have put the code at the top of the page.

Also, how do you count the line numbers? is it from top of page where <?php is, or from "do not change code below"?
Any suggestions would be much appreciated.

Thanks in advance

Logged
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #1 on: October 17, 2007, 09:26:53 AM »

Lets assume you are trying to protect members_area.php. Open password_protect.php in your favorite browser like this http://example.com/path/to/the/password_protect.php?help
It will output protection string. Add that string at the very top of the members_area.php.
Logged
abssom
Newbie
*
Posts: 3


« Reply #2 on: October 17, 2007, 03:33:11 PM »

Zubrag,
I have put the code at the top of my protected page members_area.php as per below:
-----------------------------------------------------------------
<html>
<head>
  <title>Please enter password to access this page</title>
  <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</head>
<body>
  <style>
    input { border: 1px solid black; }
  </style>
  <form method="post">
    <h3>Please enter password to access this page</h3>
    <font color="red">Incorrect password.</font><br />
Login:<br /><input type="input" name="access_login" /><br />Password:<br />    <input type="password" name="access_password" /><p></p><input type="submit" name="Submit" value="Submit" />
  </form>
  <br />
  <a style="font-size:9px" href="http://www.zubrag.com/scripts/password-protect.php" title="Download Webpage Password Protect">Powered by Webpage Password Protect</a>
</body>
</html>
----------------------------------------------------------------------------
It still gives the message below:

Warning: Cannot modify header information - headers already sent by (output started at /home/ahdiorg/public_html/members_area.php:1) in /home/ahdiorg/public_html/pass_protect/password_protect.php on line 137

The URL is as follows:
http://www.ahdi.org.uk/members_area.php
Any suggestions??
Thanks
Logged
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #3 on: October 18, 2007, 10:17:19 AM »

You do not have to add that code.
All you have to do is add following string to the member_area.php, at the top.
<?php include("/home/ahdiorg/public_html/pass_protect/password_protect.php"); ?>
Logged
abssom
Newbie
*
Posts: 3


« Reply #4 on: October 19, 2007, 02:57:21 AM »

Zubrag,

Thanks for your replies.

This is the code at the top of the members page as loaded on the server:

<?php include("/home/ahdiorg/public_html/pass_protect/password_protect.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>

When you view the page in ie7, and view the source, you get:

<html>
<head>
  <title>Please enter password to access this page</title>
  <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</head>

Am I missing something, or has it changed the code?

Thanks again.
Logged
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #5 on: October 19, 2007, 05:56:08 AM »

Hi. This is correct. Password protector has its own <html> and <header> tags. You can change them in password_protect.php if needed.

Foe example you could replace in password_protect.php following
<html>
<head>

with this code (to match your header)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
Logged
xandre
Newbie
*
Posts: 1


« Reply #6 on: December 09, 2007, 05:56:41 PM »

I have the same problem but I don't know how to solve it.
Logged
mysmallbizu
Newbie
*
Posts: 4


« Reply #7 on: December 27, 2007, 01:04:39 PM »

the php script that I'm trying to protect outputs an .asx file that plays a windows media video

<?php

   if ($_REQUEST['video']) {

      $media = $_REQUEST['video'];

      $asx  = '<asx version="3.0">'."\n";
      $asx .= '<title>MySmallBiz University Video Tutorial</title>'."\n";
      $asx .= '<copyright>MySmallBizU</copyright>'."\n";
      $asx .= '<entry>'."\n";
      $asx .= '<ref href="mms://my.mediaserver.ca/jmaduk/'.$_REQUEST['video'].'" />'."\n";
      $asx .= '<author>James Maduk</author>'."\n";
      $asx .= '<copyright>MySmallBizU.com</copyright>'."\n";
      $asx .= '</entry>'."\n";
      $asx .= '</asx>'."\n";

      header('Cache-control: public');
      header('content-Disposition: filename='.$media);
      header('content-type: video/x-ms-asf;');

      echo $asx;

   }

?>



If I add the protection code to the top of this script the videos won't play.  I believe it's because of the headers  What do I need to change in the script file to get it to work?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC