Jump to content

Recommended Posts

Well, I am getting errors like this:

 

Warning: Cannot modify header information - headers already sent by (output started at /home/content/m/a/r/markbailly/html/fcs/login.php:8) in /home/content/m/a/r/markbailly/html/fcs/login/members/login.php on line 62

 

Warning: Cannot modify header information - headers already sent by (output started at /home/content/m/a/r/markbailly/html/fcs/login.php:8) in /home/content/m/a/r/markbailly/html/fcs/login/members/login.php on line 63

 

Warning: Cannot modify header information - headers already sent by (output started at /home/content/m/a/r/markbailly/html/fcs/login.php:8) in /home/content/m/a/r/markbailly/html/fcs/login/members/login.php on line 66

 

Here is a snippet from /fcs/login.php:

 

          <div id="text" >

                <h1>Member Login</h1>

          <p><?php include("/home/content/m/a/r/markbailly/html/fcs/login/members/login.php"); ?></p>

 

And heres a snippet from /fcs/login/members/login.php:

 

// if login is ok then we add a cookie

$_POST['username'] = stripslashes($_POST['username']);

$hour = time() + 3600;

setcookie(ID_fcs, $_POST['username'], $hour);

setcookie(Key_fcs, $_POST['pass'], $hour);

 

//then redirect them to the members area

header("Location: members.php");

}

}

}

else

{

 

I will link some people to my website in a private message but not in public yet..

 

 

 

Thanks everyone!

Link to comment
https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/
Share on other sites

A header('Location: ') call must come before any output is sent to the browser. So, the include must happen before any of that html is sent.

 

Long story short, move the include to be at the beginning of login.php

 

But then it wouldn't have time to do all the info, right?

I guess I need to know more about the logic. What are the purpose of these pages:

 

/fcs/login.php

/fcs/login/members/login.php

 

/fcs/login.php Is the html where you type your username and password into and it has styles and stuff around it...

 

/fcs/login/members/login.php Is the actual php script that handles the information and it does all the stuff... blah..

Then what is the purpose of including /fcs/login/members/login.php inside of /fcs/login.php? It sounds like it should just be posting to it.

 

Ok here:

 

http://fcs.etsoldiers.com/login.php

http://fcs.etsoldiers.com/login/members/login.php

 

/fcs/members/login.php Is the whole login script and everything, including the form..

 

/fcs/login.php Is just the visuals.

ok...well...sorry to inform you, but you can't do it that way. the header() function has to be called before any output. one easy fix is to modify /fcs/login/members/login.php so that the output for the form is printed via a function let's call it... showLoginForm(). That way, when including this file, no output would be printed yet.

 

Then, in /fcs/login.php, move the include to the top of the page and use the function call later on where the include used to be.

 

Does that make sense? I would need to see the code for the two files to provide working examples.

ok...well...sorry to inform you, but you can't do it that way. the header() function has to be called before any output. one easy fix is to modify /fcs/login/members/login.php so that the output for the form is printed via a function let's call it... showLoginForm(). That way, when including this file, no output would be printed yet.

 

Then, in /fcs/login.php, move the include to the top of the page and use the function call later on where the include used to be.

 

Does that make sense? I would need to see the code for the two files to provide working examples.

 

I think I got an easier idea..

 

Why don't I just copy/paste the form (only the form....) from /fcs/login/members/login.php and have the action go to that page? Lol, easier.. right? :P

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.