Cory94bailly Posted May 4, 2008 Share Posted May 4, 2008 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: 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: 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: 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! Quote Link to comment https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/ Share on other sites More sharing options...
rhodesa Posted May 4, 2008 Share Posted May 4, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/#findComment-532983 Share on other sites More sharing options...
Cory94bailly Posted May 4, 2008 Author Share Posted May 4, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/#findComment-532987 Share on other sites More sharing options...
rhodesa Posted May 4, 2008 Share Posted May 4, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/#findComment-532998 Share on other sites More sharing options...
Cory94bailly Posted May 4, 2008 Author Share Posted May 4, 2008 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.. Quote Link to comment https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/#findComment-533019 Share on other sites More sharing options...
rhodesa Posted May 4, 2008 Share Posted May 4, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/#findComment-533045 Share on other sites More sharing options...
Cory94bailly Posted May 4, 2008 Author Share Posted May 4, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/#findComment-533047 Share on other sites More sharing options...
rhodesa Posted May 5, 2008 Share Posted May 5, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/#findComment-533214 Share on other sites More sharing options...
Cory94bailly Posted May 5, 2008 Author Share Posted May 5, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/#findComment-533652 Share on other sites More sharing options...
rhodesa Posted May 5, 2008 Share Posted May 5, 2008 MUCH! Quote Link to comment https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/#findComment-533657 Share on other sites More sharing options...
Cory94bailly Posted May 5, 2008 Author Share Posted May 5, 2008 MUCH! I got home like 20 minutes ago and I read this.. Put the form into the site, instantly worked.. lol Thanks anyways guys Quote Link to comment https://forums.phpfreaks.com/topic/104087-solved-need-help-with-a-script/#findComment-533660 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.