PhP CSS referencing

doc_t

New Member
Joined
Dec 7, 2017
Messages
2
Reaction score
0
Hi

I'm writing a Php code that should open a different CSS page after logging in, SCENARIO : once you open the web page, you get to a home page that has basically a set of messages in the headers and a paragraph. You are required to log in or signup, the signup is not a problem and once you have done signing up you can login. once you have entered your username and password, that is where the problem lies. Firstly, the Php code runs and validates your credentials then there's a condition... now when your credentials fail, you are told to either check the username or password, good. once you have entered the correct information, you are supposed to access a different page on the web, the problem lies when I call the CSS code after a successful login. Below I have attached a piece of code from both Php validation and a bit of CSS code. Please assist.

PHP
==

<section class="main-container">
<div class="main-wrapper">
<h2>Welcome...</h2>
<h3>To the photographers studio</h3>
<h4>Login or sign up FOR FREE to start showing off your work and connecting to other enthusiasts like yourself.</h4>

<p>This site is intended for all the photographers accross the globe to share their work and assist those who are aiming for the skies in terms
of their careers. if you are interested in being part of the people who wants to capture all the life moments, do not hesistate to sign up for
free. This will also help those who want to book photographers and can see their recent work and contact details.</p>
<?php
$time = time();
$actual_time = date('D M Y @ H:i:s', $time);

if(isset($_SESSION['u_uid'])){
echo 'You logged in ';
echo ' on '. $actual_time;
//include_once 'success.php';
}
?>
</div>
</section>




CSS
==

/*MY CODE*/
.main-wrapper{
margin: 0 auto;
width: 1000px;
}

a{
text-decoration: none;
}

body{

background: url(background.JPG);
background-repeat: none;
background-attachment: scroll;
background-position: 90% 50%;

}

header nav{

width: 100%;
height: 60px;
background-color: #fff;
}

header nav ul{
float: left;
}
header nav ul li{
float: left;
list-style: none;

}

header nav ul li a{
font-family: arial;
font-size: 36px;
color: green;
line-height: 63px;
}
header .nav-login{
float: right;

}
header .nav-login form {
float: left;
padding-top: 15px;
}

header .nav-login form input {
float: left;
width: 140px;
height: 30px;
padding: 0px 10px;
margin-right: 10px;
border: none;
background-color: #ccc;
font-family: arial;
font-size: 14px;
color: #111;
line-height: 30px;
}

header .nav-login form button {
float: left;
width: 60px;
height: 30px;
margin-right: 10px;
border: none;
background-color: #f3f3f3;
font-family: arial;
font-size: 14px;
color: #111;
cursor: pointer;

}
header .nav-login form button:hover {
background-color: #ccc;
}
header .nav-login a {
display: block;
width: 60;
height: 60px;
border: none;
float: left;
background-color: #fff;
font-family: arial;
font-size: 16px;
color: #111;
line-height: 63px;
cursor: pointer;
}
.main-container{

padding-top: 40px;
}
.main-container h2{
font-family: arial;
font-size: 80px;
color: #ccc;
line-height: 50px;
text-align: center;
font-style: italic;
}
.main-container h3{
font-family: arial;
font-size: 50px;
color: #ccc;
line-height: 90px;
text-align: center;
font-style: underline;
}
.main-container h4{
font-family: arial;
font-size: 20px;
color: yellow;
line-height: 30px;
text-align: center;
font-style: bold;
}
.main-container p{
font-family: arial;
font-size: 20px;
color: white;
line-height: 25px;
text-align: center;
font-style: bold;
background-image: Screenshot_6.jpg;
}
 
Sorry what is the actual question or problem?
 
Either have a different set of pages for logged in users and logged out users which has a different css file linked if thats what you want, or you can do a test for logged in user:

if (isset($_SESSION['u_uid']))
{
echo "<link rel='stylesheet' type='text/css' href='css/authenticated.css'>";
}
else
{
echo "<link rel='stylesheet' type='text/css' href='css/anonymous.css'>";
}

Otherwise if you want css per user assign a css file to the user in the db and keep it in the session ($user session or similar):

DB:
ID, Name, User, Pass, CSSfile
1, George, george, ******, george.css
2, Jacob, jacob, ******, jacob.css

PHP:
/* on successful login */
if (isset($_SESSION['u_uid']))
{
echo 'You logged in ';
echo ' on '. $actual_time;
echo "<link rel='stylesheet' type='text/css' href='css/$user->CSSfile'>";
}
?>
 
Top
Sign up to the MyBroadband newsletter