00001 <?php
00011
00012
00013 session_start();
00014
00017 session_register('logged_in');
00018
00019
00020
00021
00022 require('common_functions.php');
00023
00024
00027 $message='';
00028
00029
00039 function get_post($var1)
00040 {
00041 if(isset($_POST[$var1]))
00042 return $_POST[$var1];
00043 else
00044 return "";
00045 }
00046
00047
00048
00055 function show_login_page()
00056 {
00057 global $message;
00058 ?>
00059 <html>
00060 <head>
00061 <title>Login page</title>
00062 </head>
00063 <body>
00064 <?php echo $message; ?>
00065 <form action="index.php" method="POST">
00066 Username: <input type="text" name="username1" value="" /> <br/>
00067 Password: <input type="password" name="password1" value="" /> <br/>
00068 <input type="submit" value="Login" name="submit1" /><br/>
00069 </form>
00070 </body>
00071 </html>
00072 <?php
00073 }
00074
00075
00088 function main()
00089 {
00090 global $message;
00091
00092
00093 $username1=get_session('logged_in');
00094
00095
00096
00097 if($username1!="")
00098 redirect('welcome.php');
00099 else if(get_post('submit1')=="")
00100 {
00101
00102
00103 show_login_page();
00104 }
00105 else
00106 {
00107
00108
00109 $username1=get_post('username1');
00110 $password1=get_post('password1');
00111
00112 if($username1==$password1 && $username1!="")
00113 {
00114
00115
00116
00117 $_SESSION['logged_in']=$username1;
00118 redirect('welcome.php');
00119 }
00120 else
00121 {
00122
00123
00124
00125
00126 $message="Sorry! Username and password do not match.<br/>\n";
00127 show_login_page();
00128 }
00129 }
00130 }
00131
00132
00133 main();
00134
00135 ?>