FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » php sessions and css file?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: php sessions and css file? [message #173666 is a reply to message #173664] Tue, 26 April 2011 15:09 Go to previous messageGo to previous message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma:
Senior Member
On 4/26/2011 10:46 AM, Alex Pavluck wrote:
> Is it possible to use a css file if you are using php sessions to
> login?

Why not? What has one thing to do with the other. If you are chewing
gum, can you write on a piece of paper? See what I mean?

One thing you need to get clear in your mind: PHP is _SERVER SIDE_
code. It has absolutely _NOTHING_ to do with the display. CSS is
_CLIENT SIDE_ code and ONLY has to do with the display. Yes, using PHP
you can code print or echo statements of html code do display to the
browser, and when done it will use the CSS that is included in the
output, but ALL of that is done on the server. It is only when it gets
to the browser -- and has absolutely NO knowledge that PHP, ASP or
anything else on the server generated it -- that it uses the CSS.

BTW, you are NOT using php sessions to log in. You are using php
sessions to remember and determine _IF_ you are logged in.

>
> Here is my code:
>
> valid.php
> ....
> if($count==1){
>
> $_SESSION['loggedin'] = 1;// Set session variable
> header("Location: protect.php");//header must be the first printed
> line!
>
> protect.php
> <?php
> session_start();
> // Call this function so your page
> // can access session variables
> if($_SESSION['loggedin'] != 1) {
> // If the 'loggedin' session variable
> // is not equal to 1, then you must
> // not let the user see the page.
> // So, we'll redirect them to the
> // login page (login.php).
> header("Location: index.html");
> exit;
> }
> ?>
>
>
> <html>
> <head>
> <title>DOLF Project Log In</title>
> <link rel="stylesheet" type="text/css" href="layout.css"
> media="screen" />
>
> </head>
> <body>
> ....

Now, looking at your code I have no idea what $count comes from, nor
what $valid is used for. From appearances it looks like you will send
the user to the index.html (NOT the login page, unless the index page IS
the log in page) if that $count variable is somehow not equal to one.

Also, from the way you put it here, I thing you REALLY want protect.php
to be terminated after the ?>. You would then have a

<?php
require_once 'protect.php"
?>

at the top of every file you want to protect (before the <html> line).
Remember that everything between the <?php and the ?> is processed on
the server BEFORE it is delivered to the browser.

Oh, you also need an actual log in page for the user to put in a user
name and a password. That is where you would set the session variable.

--
Shelly
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Adding a CDATA section
Next Topic: hai
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 17:40:21 GMT 2024

Total time taken to generate the page: 0.05346 seconds