Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Zablokowanie podstrony " strona dostępna po zalogowaniu, Jak zablokować stronę,aby była dostępna po zalogowaniu ?
kiepski96
post
Post #1





Grupa: Zarejestrowani
Postów: 233
Pomógł: 0
Dołączył: 22.02.2010

Ostrzeżenie: (0%)
-----


Chciałbym zabezpieczyć wszystkie podstrony mojej strony,oprócz rejestracji,aby były dostępne wyłącznie po zalogowaniu.
Jeśli się ktoś nie zaloguje i np. wpisze w przeglądarkę:

www.aaa.pl/podstrona1.html to aby przekierowało go na logowanie.


Jaki dać kod do podstron ?


Proszę o szybką odpowiedź.
Powód edycji: [strife]: Dodałem tag
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kiepski96
post
Post #2





Grupa: Zarejestrowani
Postów: 233
Pomógł: 0
Dołączył: 22.02.2010

Ostrzeżenie: (0%)
-----


Tutaj skrypt logowania:

  1. <?php
  2. if($_SERVER['REQUEST_METHOD'] == 'POST')
  3. {
  4. $success_page = './Kategorie.php';
  5. $error_page = './error.html';
  6. $mysql_server = 'localhost';
  7. $mysql_username = 'xxx';
  8. $mysql_password = 'xxx';
  9. $mysql_database = 'xxx';
  10. $mysql_table = 'reg1';
  11. $crypt_pass = md5($_POST['password']);
  12. $found = false;
  13. $fullname = '';
  14.  
  15. $db = mysql_connect($mysql_server, $mysql_username, $mysql_password);
  16. mysql_select_db($mysql_database, $db);
  17. $sql = "SELECT password, fullname, active FROM ".$mysql_table." WHERE username = '".$_POST['username']."'";
  18. $result = mysql_query($sql, $db);
  19. if ($data = mysql_fetch_array($result))
  20. {
  21. if ($crypt_pass == $data['password'] && $data['active'] != 0)
  22. {
  23. $found = true;
  24. $fullname = $data['fullname'];
  25. }
  26. }
  27. if($found == false)
  28. {
  29. header('Location: '.$error_page);
  30. }
  31. else
  32. {
  33. $_SESSION['username'] = $_POST['username'];
  34. $_SESSION['fullname'] = $fullname;
  35. header('Location: '.$success_page);
  36. }
  37. }
  38. $username = isset($_COOKIE['username']) ? $_COOKIE['username'] : '';
  39. $password = isset($_COOKIE['password']) ? $_COOKIE['password'] : '';
  40. ?>
  41. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  42. <html>
  43. <head>
  44. <meta http-equiv="Content-Language" content="pl">
  45. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  46. <title>Restockerz Script Pro</title>
  47. <meta name="keywords" content="script,restockerz">
  48. <meta name="author" content="domino1">
  49. <meta name="categories" content="Restock script">
  50. <link rel="shortcut icon" href="favicon.ico">
  51. <style type="text/css">
  52. body
  53. {
  54. background-color: #000000;
  55. color: #000000;
  56. }
  57. </style>
  58. </head>
  59. <body>
  60. <div id="wb_Shape1" style="margin:0;padding:0;position:absolute;left:0px;top:100px;width:1276px;height
    :40px;text-align:center;z-index:0;">
  61. <img src="images/img0001.png" id="Shape1" alt="" title="" style="border-width:0;width:1276px;height:40px"></div>
  62. <div id="wb_Image1" style="margin:0;padding:0;position:absolute;left:15px;top:0px;width:200px;height:1
    00px;text-align:left;z-index:1;">
  63. <img src="images/logo.png" id="Image1" alt="" border="0" style="width:200px;height:100px;"></div>
  64. <div id="wb_Shape2" style="margin:0;padding:0;position:absolute;left:51px;top:105px;width:81px;height:
    28px;text-align:center;z-index:2;">
  65. <a href="./index.php"><img src="images/img0002.png" id="Shape2" alt="" title="" style="border-width:0;width:81px;height:28px"></a></div>
  66. <div id="wb_Shape3" style="margin:0;padding:0;position:absolute;left:149px;top:105px;width:81px;height
    :28px;text-align:center;z-index:3;">
  67. <a href="./symulator.php"><img src="images/img0003.png" id="Shape3" alt="" title="" style="border-width:0;width:81px;height:28px"></a></div>
  68. <div id="wb_Shape4" style="margin:0;padding:0;position:absolute;left:247px;top:105px;width:81px;height
    :28px;text-align:center;z-index:4;">
  69. <a href="./pomoc.php"><img src="images/img0004.png" id="Shape4" alt="" title="" style="border-width:0;width:81px;height:28px"></a></div>
  70. <div id="wb_Login2" style="margin:0;padding:0;position:absolute;left:470px;top:322px;width:265px;heigh
    t:143px;text-align:left;z-index:5;">
  71. <form name="loginform" method="post" action="<?php echo basename(__FILE__); ?>" id="loginform">
  72. <table cellspacing="6" cellpadding="0" style="background-color:#388E8E;border-color:#388E8E;border-width:1px;border-style:solid;color:#000000;font-family:Times New Roman;font-size:17px;width:265px;height:143px;">
  73. <tr>
  74. <td colspan="2" align="center" style="height:23px;background-color:#DFE9F5;color:#387AC8;">Logowanie</td>
  75. </tr>
  76. <tr>
  77. <td align="left" style="height:21px;width:70px">Nick:</td>
  78. <td align="left"><input name="username" type="text" id="username" value="<?php echo $username; ?>" style="width:150px;height:18px;background-color:#FFFFFF;border-color:#DFE9F5;border-width:1px;border-style:solid;color:#000000;font-family:Times New Roman;font-size:17px;"></td>
  79. </tr>
  80. <tr>
  81. <td align="left" style="height:21px">Hasło:</td>
  82. <td align="left"><input name="password" type="password" id="password" value="<?php echo $password; ?>" style="width:150px;height:18px;px;background-color:#FFFFFF;border-color:#DFE9F5;border-width:1px;border-style:solid;color:#000000;font-family:Times New Roman;font-size:17px;"></td>
  83. </tr>
  84. <tr>
  85. <td>&nbsp;</td><td align="left" valign="bottom"><input type="image" name="login" id="login" src="images/loginbutton.png"></td>
  86. </tr>
  87. </table>
  88. </form>
  89. </div>
  90. <div id="wb_Shape6" style="margin:0;padding:0;position:absolute;left:346px;top:105px;width:81px;height
    :28px;text-align:center;z-index:6;">
  91. <a href="./Rejestracja.php"><img src="images/img0089.png" id="Shape6" alt="" title="" style="border-width:0;width:81px;height:28px"></a></div>
  92. </body>
  93. </html>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 14.10.2025 - 05:55