User-select template change - help

Discussion in 'PHP' started by Lpspider, Oct 30, 2006.

  1. #1
    Okay, this is what I have:


    
    <?php 
    
    $title = "Template Page";
    
       echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd" />'; 
       echo '<head><title>' ,$title, '</title>'; 
    
      switch ($_POST['style']) 
        { 
        case "default": 
            echo '<link rel="stylesheet" href="style1.css" type="text/css"/>'; 
            break; 
        case "black": 
            echo '<link rel="stylesheet" href="style2.css" type="text/css"/>'; 
            break; 
        case "purple": 
            echo '<link rel="stylesheet" href="style3.css" type="text/css"/>'; 
            break; 
        case "white": 
            echo '<link rel="stylesheet" href="style4.css" type="text/css">'; 
            break; 
        case 0: 
            echo '<link rel="stylesheet" href="style1.css" type="text/css"/>'; 
            break; 
        } 
    
    
       echo '</head><body>'; 
     
       echo '<form action="index.php" method="post">
             <select name="Template"> 
             <option type="radio" value="default" name="style">Default</option> 
             <option type="radio" value="black" name="style">Black</option> 
             <option type="radio" value="purple" name="style">Purple</option> 
             <option type="radio" value="white" name="style">White</option></select>
             <input type="submit" name="Change Style" /></form>'; 
    
       echo '<div class="nav"><a href="index.php">Home</a> | <a href="register.php">Register</a> | <a href="links.php">Links</a> | <a href="faq.php">FAQ</a></div>'; 
    
        echo '</body></html>';
    
    ?>
    
    PHP:
    And here's 1 of 4 style sheets:

    
    
    <style type="text/css">
    
    div.nav
    {
    position:absolute;
    top:75px;
    left:10%;
    right:10%;
    width:80%;
    background-color:#0099FF;
    text-align:right;
    }
    
    body
    {
    background-color:#333333;
    }
    
     </style>
    
    
    
    
    PHP:
    When I select and reload the page it just shows the content with a white background, not the bg color specified in the CSS.
     
    Lpspider, Oct 30, 2006 IP
  2. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think it's the stylesheet. Is the php showing
    <link rel="stylesheet" href="stylex.css" type="text/css"/>
    correctly - i.e. changing the stylesheet ?

    EDIT -
    Actually it's the select name :
    change it to :

    <select name="style"> 
    Code (markup):
     
    maiahost, Oct 30, 2006 IP
    Lpspider likes this.
  3. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Thanks. I just tried changing the select name to "style" yet it still doesn't work. I get the same effect.

    Any other ideas or suggestions? It'd be greatly appreciated.
     
    Lpspider, Oct 31, 2006 IP
  4. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #4
    I think you're right though about the style sheet. For some reason it's not sending it to the page. I know this because I printed unique text on each style sheet and ran the script - but the text didn't show no matter what I selected.

    Any thoughts or ideas?
     
    Lpspider, Oct 31, 2006 IP
  5. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #5
    I hate to tripple post but I can here's a little update. Basically I can get the default case ( case 0 ) to show and use that style sheet. However, I can't select one and have it use it. Apparently when I submit it doesn't send the data (or doesn't accurately read the data) to select the proper style sheet.
     
    Lpspider, Oct 31, 2006 IP
  6. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #6
    Got it! Thanks!
     
    Lpspider, Oct 31, 2006 IP
  7. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #7
    What was the problem - the default value ? It was working here yesterday but I removed the 0 and default.
     
    maiahost, Oct 31, 2006 IP
  8. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #8
    Two problems.

    1) the select name, as you said.
    2) I had foolishly misnamed a file... rather than .css I had .php. :eek:
     
    Lpspider, Oct 31, 2006 IP