5kyy8lu3 Posted December 10, 2008 Share Posted December 10, 2008 I just finished my MySQL for Dummies book and I've messed around with a few things trying to teach myself. Basically I'm a noob. Here's what I have working right now: You load the webpage. You type in login info. Via _POST the submitted info sends the user to the login check page where checks the info against what's in the table. If it's correct, you get header(); to the welcome page, and if the info is wrong, it says it's incorrect and gives a link to go back to try again. What I want: I added a column in my table called permissions. After validating the login info is "ok", I want it to goto a different page depending on what info is in the permissions column for that username. Basically, I want a "back-end" page where I can use my MYSQL query page and other admin related stuff from logging in and having a "1" as my permission level, but if anyone else logs in they get different content. From what I've seen, PHP doesn't like me using header(); more than once in a page. So, how would I create dynamic content? What I'm thinking might work: I could just set a cookie variable to the permission level and use IF statements in the "logged in page" to display links to admin content (or not) depending on the permission level. Is this the way to go about it? Please know that I'm a noob, I know html very well and I've done a little C++ in the past so I'm not a complete programming noob but as far as PHP goes it's new to me, so ANY help would be very much appreciated. Thanks ahead of time, and sorry for the wall of text, I'm not very good at summarizing. Link to comment https://forums.phpfreaks.com/topic/136313-dynamic-content-help-please/ Share on other sites More sharing options...
haku Posted December 10, 2008 Share Posted December 10, 2008 You can use headers more than once in a page (you can set as many headers as you want), you just can't send headers to the browser after content has been sent to the browser. The key here is re-structuring your code to do any username/password checking before the output to the browser, then have your forward happen at that point. Link to comment https://forums.phpfreaks.com/topic/136313-dynamic-content-help-please/#findComment-711152 Share on other sites More sharing options...
5kyy8lu3 Posted December 10, 2008 Author Share Posted December 10, 2008 You can use headers more than once in a page (you can set as many headers as you want), you just can't send headers to the browser after content has been sent to the browser. The key here is re-structuring your code to do any username/password checking before the output to the browser, then have your forward happen at that point. weird, the ONLY html on the page was after the headers in the else section that says you got the password wrong, hmmm lemme go see what I can find, if all else fails I'll post the code, thanks for the help Link to comment https://forums.phpfreaks.com/topic/136313-dynamic-content-help-please/#findComment-711157 Share on other sites More sharing options...
haku Posted December 10, 2008 Share Posted December 10, 2008 Not just html, but content. content includes whitespace. So if you have any whitespace before your opening php tags, that is sent to the browser, and will stop your headers from being able to be executed. This is an important point, especially if you are including files - you have to check for whitespace before the opening php tags in those files as well. Link to comment https://forums.phpfreaks.com/topic/136313-dynamic-content-help-please/#findComment-711158 Share on other sites More sharing options...
5kyy8lu3 Posted December 10, 2008 Author Share Posted December 10, 2008 Not just html, but content. content includes whitespace. So if you have any whitespace before your opening php tags, that is sent to the browser, and will stop your headers from being able to be executed. This is an important point, especially if you are including files - you have to check for whitespace before the opening php tags in those files as well. ah, i did change a few other things when i added the permissions checking, i probably left a white space somewhere, i really appreciate the help Link to comment https://forums.phpfreaks.com/topic/136313-dynamic-content-help-please/#findComment-711172 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.