Join us now. It is free, and it takes less than 1 minute to register.
Register now
Subscribe to our daily newsletter. It is free, and it comes with many benefits.


+ Reply to Thread
Results 1 to 3 of 3

Thread: PhP CSS referencing

  1. #1
    Junior Member
    Join Date
    Dec 2017
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default PhP CSS referencing

    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;
    }

  2. #2
    Senior Member
    Join Date
    Aug 2017
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sorry what is the actual question or problem?

  3. #3
    Grandmaster
    Join Date
    Feb 2009
    Posts
    3,169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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'>";
    }
    ?>

+ Reply to Thread

Similar Threads

  1. Word 2010 referencing/hyperlink errors
    By AvatarS in forum Software
    Replies: 2
    Last Post: 17-03-2014, 02:44 PM
  2. Referencing a company report
    By GPSJane in forum Off Topic
    Replies: 8
    Last Post: 22-09-2011, 02:22 AM
  3. Harvard referencing : song lyrics ??
    By bodhi in forum Off Topic
    Replies: 0
    Last Post: 17-02-2008, 01:22 PM
  4. Referencing in a thesis
    By Bravestar in forum Off Topic
    Replies: 13
    Last Post: 18-12-2007, 05:45 PM
  5. Javascripting-referencing seperate windows
    By Jonny Two Shoes in forum Off Topic
    Replies: 2
    Last Post: 04-12-2006, 09:23 PM

Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •