473,326 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Session won't work.

Thew
69
I want to create an admin session to display a div on my website with stats, unviewable for everyone except for me. So i wrote this script:


AdminSessionLogin.php
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. include 'header.php';
  4.  
  5. $ip = $_SERVER['REMOTE_ADDR'];
  6. $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
  7. $pass = $_POST['pass'];
  8. $adminsetpass = "AdminPass";
  9.  
  10. if($ip = "My ip"){
  11.     if($hostname = "My ISP"){
  12.         echo '<form action="" method="post">
  13.               <input type="password" name="pass">
  14.               <input type="submit" value="sumbit"><br>
  15.              ';
  16.     }
  17.     else
  18.     {
  19.     echo 'Hostname not right!';
  20.     }
  21. }
  22. else
  23. {
  24. echo 'ip Not right!!';
  25.  
  26. if($_SERVER['REQUEST_METHOD'] == "POST"){
  27.     if($pass == $adminsetpass){
  28.  
  29.         $_SESSION['admin'] = "true";
  30.         echo 'Done';
  31.  
  32.     }
  33.     else
  34.     {
  35.         echo 'Pass not right!';
  36.     }
  37. }
  38. include 'footer.php';
  39. ?> 
  40.  
Header.php:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. session_start();
  4.  
  5. // a lot code
  6.  
  7. // Now here is the place where the div has to be:
  8.  
  9. if(isset($_SESSION['admin'])){
  10.     if($_SESSION['admin'] == "true"){
  11.     echo '<div style="display:block; bottom:0;   position:fixed; text-align: center; width: 900px; background-color:red; font-size:10px;">
  12.           <?php include "online.php"; ?> 
  13.           </div>
  14.           ';
  15.  
  16.     }
  17. }
  18. ?>
  19.  
I include header.php and footer.php and on every page, with the content between the includes.

But now the div won't show up. Can you all help me out?
Aug 19 '10 #1

✓ answered by MrMancunian

Try to see if loops are entered by echoing variable values to your page. See which values are showing up and which are not. I can't immediately see an error in your code, so try this suggestion first. If you can't find it, let us know...

Steven

2 1759
MrMancunian
569 Expert 512MB
Try to see if loops are entered by echoing variable values to your page. See which values are showing up and which are not. I can't immediately see an error in your code, so try this suggestion first. If you can't find it, let us know...

Steven
Aug 19 '10 #2
Thew
69
Hi

It worked thanks

Thew
Aug 20 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jim | last post by:
Hey guys I DESPERATLY need some help with this small javascript i have on this website. All that it's supposed to do is change the button image once it's pressed but alas... I copy-pasted the code...
4
by: Mark | last post by:
the Following bit of code doesn't work. It seems to respond to the second, starting with 'add iif statement for Good Practice', but not to the first, starting 'add iif statement for archived' ...
5
by: Dean | last post by:
I have notice a couple of other threads here that depict the same problem I am having: I can't get session state to work. I wrote a component class to do all of my database access and use it in...
4
by: Chad | last post by:
I have a link (.ascx) and that generates an Add form on that page. The autopostback dropdown is within a "If Not IsPostBack Then" statement. The form that is created is all via static html in the...
7
by: simon | last post by:
I have simple html(aspx) page, but vertical height won't work. Even if i had set the height of a table=100%, the table is not 100% height. I spend a lot of time(my real page is more...
3
by: musosdev | last post by:
Hi guys Okay, I've setup my projects to open and compile fine in VS2005 using FPSE and remote web, but it's *really* slow. So I thought I'd have a go at doing it the normal way, by loading from...
6
by: b. hotting | last post by:
Hi, I don't see why this won't work, it are 3 links, the last one (a get) does work, but the first 2 won't. i would like to use a post, through hidden input types any idea? thanks for your...
7
by: Eran.Yasso | last post by:
Hi, I have project that automate excel(using Excel COM) which works fine in my home. I took the project from my home to work and tried to build the project but it won't built. I get error "The...
1
by: tony | last post by:
I have a asp.net 1.1 website that works fine when I hit it from within the lan remotely, but when I am on the same machine and hit it, it seems that the app isn't able to use the session object. ...
4
by: z55177 | last post by:
My domain: http://www.esthevision.cz/ This is the cause of my problem. The template is supposed to look somewhat like this: PINK STRIPE http://themebot.com/website-templates/ht... I created an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.