|
Registration Area
→ layout
any_reserved_member_page.php
Nb : you can access any_reserved_member_page.php and view the related-page-layout only after demo-logging. If not logged you will be redirected to login in the main page If you forgot the data, please register again. |
$cookie_name = "member";# Remember that cookie is a php header and no space... $cookie_value ="logged";# ...or html output has to be set before the cookie setting... setcookie($cookie_name, $cookie_value);# ....................the cookie would not be set ! require("common.php"); $check_AU="SELECT posta FROM auth_users WHERE (login='$login')AND(password='$password')"; $query=mysql_query($check_AU,$connessione); $num_righe=@mysql_num_rows($query); if ( $num_righe != 0){ $id_result=mysql_query ($check_AU,$connessione); echo "Your data have been inserted and your e-mail is : <center><table width=\"123\" border=\"3\"cellpadding=3>"; while($tabposta = mysql_fetch_array($id_result,MYSQL_ASSOC)) {echo"<tr><td align=center nowrap>$tabposta[posta]</td></tr>";}echo"</table></center>"; echo"</table><center><br>...you have been successfully registered !</center></td></tr> <tr><td colspan=2 align=right valign=top> Of course you will direct this action towards a login window to convalidate the access data of your users,<br>see the <b>Php_Bay demo</b> on our home page. <b><div align=right><br> <a href=\"registration_scripts_main.php\">Registration Area</a> <a href=#layout>layout</a><br> <a href=any_reserved_member_page.php>Any Reserved Member Page</a> </td></tr></table>"; mysql_close($connessione);} else{/* Start of else Nb: If no value has been sent by form no record row is found and no output is given till here */
setcookie($cookie_name); /* This header-line would not be sent if above red code is set ! you will take your time later to get deeper into the details, so you may well skip them, if you are new to PHP For to cancel a cookie in PHP, is enough to call the php-function setcookie(); like it is here, by passing as argument only its name and no value. Now, as the member is not logged, let's cancel the cookie because if the access data are not correct or there is no access data, the cookie would be set anyway and by pasting the address of any member page, after the login page has been unsuccessfully loaded, the reserved page would be returned thanks the cookie : member=logged ( see the layout of any_reserved_member_page.php ...you first have to be demo-logged ) . But you would say the cookie is set at the beginning of the page , how it comes that here is considered unset as this conditional expression switches in ? ( well the cookie is not set, but is going to be set by loading this page into the Client machine ) Cookie is a PHP header in php language , and when this page was requested to the server, the headers for that page were already sent , and there was no such a pre-existing cookie on the Client machine, this is going to be set now ( on this loading ) , so it comes that the value of member is : "logged" at this point while unsuccessful login and so, by calling the php-function setcookie(), just the sole cookie name... Infact we should set an echo instruction before setcookie($cookie_name); to be able to read the cookie that is going to be set : We can anyway, for testing purposes, bear the error and set the monitoring code : echo"<br>$cookie_value<br>"; to get the error and the value : "logged" ( --- we really do not need such an obvious test, but there is no other way, and of course the complete cookie , implemented at the beginning of this page, would be set and active, after the interruption of sending the updating-header : setcookie($cookie_name); ...if we now link to any member page we can get it, although we have not set any access data --- ) */mysql_close($connessione); } echo" <table width=100% height=100% cellpadding=16> <tr> <td> "; if($member=="logged"){ echo"<center><font color=green size=6><b>You are logged in !<br> <small>Test Page = Login</b></small></font><br>This is the output of another section of test-page... </center>";} if($member!="logged"){ echo"<center><font color=green size=6><b>No record has been found !</b></font></center>";} echo"<div align=right><big> <a href=\"registration_scripts_main.php\">Registration Area</a> <b> <a href=any_reserved_member_page.php>any_reserved_member_page.php</a> </div> </td></tr></table> </big>"; /* End of else */} ?> <!--<html>... html content ( in this case this layout ) </html> --> |