Ok, there are many ways to do this, but i think the siplest would be to make a page that will say that the user is logged on, and then provide a link to the page that you want them to going to.
Another great way to do this is instead of having the script reroute the user to another page, have the contents of the page show up in the same window, for that all you need to do is combine your pages into functions i.e. put the code of the page inside a function, put all functions in one file say page_fns.php and then require the file in the page that you want me to rewrite.
See, what you have to understand is that PHP is a server side language, so you can't really interact with users browser unless you request a variable from it, send them a form to fill out or pass vars through urls that you provide.
Another point here, what you are doing is really not safe security-wise. You should really store these passwords encrypted in a database or if you dont have one available, in a file that is much harder to access on your server than getting the code for your page.
Ok finally, there is a better way of doing what you are doing (code-wise), cleaner and faster anyhow:
- Code: Select all
//this will come out of what i said before about putting the code for the
//pages in functions and then executing them if you need to
require_once['page_fns.php']; //page_fns.php - pages functions file
coach_page($password); //i would check for the password on the page
//just so noone can try to execute it without a propper password
default_page; // here you can put the form that you used before
//note i do not see where you derive $password from, but i hope
//that you handled it earlier in the script
if you have any questions about the switch function
click the link...