16-09-2006, 13:00
|
|
|
חבר מתאריך: 17.05.04
הודעות: 1,454
|
|
הגדרת סשן לא עובדת..
יש לי שני קבצים :
log.php:
קוד PHP:
<? session_start(); $_SESSION['manager'] = false; if($_SESSION['manager'] && $_GET['out']){ $_SESSION['manager'] = false; header ("Location:index.php"); } if($_SERVER['REQUEST_METHOD'] != 'POST'){ echo' <form method="post" action="'.$_SERVER['PHP_SELF'].'"> <input type="text" name="user" /> <input type="password" name="password" /> <input type="submit" /> </form>'; die(); } elseif($_SERVER['REQUEST_METHOD'] == 'POST' && ($_POST['user'] != 'user' || $_POST['password'] != 'pass')){ echo 'User & Passowrd are incorrect.'; die(); } $_SESSION['manager'] = true; header ("Location:index.php"); ob_start(); ?>
index.php:
קוד PHP:
<? session_start(); function read($file){ $file = file_get_contents($file); if(!$_SESSION['manager']) return str_replace("\r\n", "<br />", $file); return $file; } function post($file, $data){ return file_put_contents($file, $data); } if($_SESSION['manager'] && $_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['bodycontent'])) post('osr.txt', $_POST['bodycontent']); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <title> O.S.R Marine Supervision </title> <style type="text/css"> body{ margin-top:100px; } #bar{ width:597px; height:60px; margin:auto; } #logo{ float:left; } #services, #resume{ float:right;margin-right:1px; } #body{ width:597px; height:388px; margin:auto; margin-top:10px; } #content{ margin-top:-4px; margin-bottom:-4px; background-color:#dfeaeb; } .edit{ direction: ltr; overflow:hidden; } img{ border:0px; } </style> <script type="text/javascript"> function image_replace(image_id,replace_image){ document.getElementById(image_id).src = replace_image; } </script> </head> <body> <div id="bar"> <span id="logo"><a href="index.php"><img src="images/logo.gif" alt="logo" /></a></span> <span id="resume"><a href="resume.php" title="CEO'S RESUME""><img src="images/resume.gif" alt="resume" id="resumeimg" /></a></span> <span id="services"><a href="services.php" title="Services"><img src="images/services.gif" id="servicesimg" alt="services" /></a></span> </div> <div id="body"> <img src="images/ship.gif" style="margin-bottom:5px;" alt="ship" /> <img src="images/bodylogo.gif" style="margin-bottom:0px;" alt="logo" /> <div id="content"><span style="direction:ltr; position:relative;left:5px;"> <? if($_SESSION['manager']){ echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'"> <textarea style="width:595px; height:200px; background-color:#dfeaeb; border:0px;" class="edit" name="bodycontent">'.read('osr.txt').'</textarea><br /><input type="submit" /> </form> <a href="log.php?out=true">Log Out</a>'; } else echo read('osr.txt'); ?> </span> </div> <img src="images/bottombody.gif" alt="bottom" /> </div> </body> </html>
אני מכניס את השם משתמש וסיסמא ב log.php אך משום הסשן לא קיים ב index.php..
עשיתי בדיקה באינדקס אם הסשן קיים או לא, והוא לא קיים לא באינטרנט אקספלורר ולא בפיירפוקס, אך משום מה כן מופיע באופרה..
יש רעיונות?
אני יודע שהקוד לא נראה משהו - פשוט לא היה הרבה זמן
_____________________________________
EVERYTHING SHOULD BE MADE AS SIMPLE AS POSSIBLE, BUT NOT ONE BIT SIMPLER
ALBERT EINSTEIN
נערך לאחרונה ע"י Rs3k בתאריך 16-09-2006 בשעה 13:02.
|