|
||||||||||||
|
If you have any doubts with your PHP code please discuss it in the PHP Forum Password Protect a Webpage using PHP | My SQLSometimes some pages need to be password protected. For example some websites have special privileages for members --- access to certain pages may be reserved only for members. This can be done in two ways.
In this tutorial I am explaining how this can be done using MySql database as backend. The situation can be summarized as follows. There are 2 webpages, say page1 and page2 that need to be password protected. Login information is stored in the table tb_signup. The code for page1.php is as follows. <?php <html> <?php </body> Explanation of the above code: Here the session is started and checks whether the user has already logged in.. If the user has logged in the content of the page will be displayed. Otherwise login.php is called to login. login.php <?php <h1>Login Here</h1> <?php if(isset($_POST['submit'])){ $_SESSION['cust_logged_in']='true'; $_SESSION['valid_user']=$userid; print "<script>"; } In a similar way we can include login.php in page2 also. We have to add username and password to the table tb_signup. Copyright © 2008 www.worth2read.org. All rights Reserved. Use of this Site is subject to our Privacy Statement |
| ||||||||||
| PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide |
||||||||||||
| Programming PHP |
||||||||||||