Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #1294
| From | sheldonlg <sheldonlg@thevillages.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: php sessions and css file? |
| Date | 2011-04-26 11:09 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <ip6n6u$tab$1@dont-email.me> (permalink) |
| References | <77c2d91e-a1ca-4aed-aa76-f1ee0f67701e@k11g2000yqc.googlegroups.com> |
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
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
php sessions and css file? Alex Pavluck <apavluck@gmail.com> - 2011-04-26 07:46 -0700
Re: php sessions and css file? Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-04-26 17:03 +0200
Re: php sessions and css file? sheldonlg <sheldonlg@thevillages.net> - 2011-04-26 11:09 -0400
Re: php sessions and css file? Alex Pavluck <apavluck@gmail.com> - 2011-04-26 10:08 -0700
Re: php sessions and css file? Jerry Stuckle <jstucklex@attglobal.net> - 2011-04-26 13:50 -0400
Re: php sessions and css file? sheldonlg <sheldonlg@thevillages.net> - 2011-04-26 15:29 -0400
Re: php sessions and css file? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-04-28 02:24 +0200
Re: php sessions and css file? sheldonlg <sheldonlg@thevillages.net> - 2011-04-27 20:30 -0400
Re: php sessions and css file? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-04-28 21:15 +0200
Re: php sessions and css file? Alex Pavluck <apavluck@gmail.com> - 2011-04-26 12:53 -0700
Re: php sessions and css file? sheldonlg <sheldonlg@thevillages.net> - 2011-04-26 16:05 -0400
Re: php sessions and css file? Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-04-27 07:58 +0200
csiph-web