Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Styl jako zmienna w adresie., Jak to zrobić?
-Tarr-
post
Post #1





Goście







Mam problem: jak zrobić , żeby ktoś na stronie mógł wybrać styl CSS, i żeby ten wybór zapisywało najlepiej jako ciasteczko. Adres wyglądałby wtedy jakoś tak: index.php?podstrona=x&styl=y . Podstronyw linkach wpisuję ręcznie, ale styl byłby stały dla każdej. Mam nadzieję, że napisałem to jasno.

Z góry dzięki za pomoc.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
-Tarr-
post
Post #2





Goście







  1. <?php
  2.  echo '<?xml version="1.0" encoding="iso-8859-2">';
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head>
  7. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
  8. <meta http-equiv="reply-to" content="" />
  9. <meta name="generator" content="WebSite PRO 4.3" />
  10. <meta name="author" content="" />
  11. <meta name="description" content="" />
  12. <title>Bez Tytułu</title>
  13. </head>
  14. <body>
  15. <?php
  16.  
  17. if( isset( $_SESSION[ 'styleId' ] ) )
  18. {
  19. $intStyleId = (int)$_SESSION[ 'styleId' ];
  20. }
  21. else
  22. {
  23. if( isset( $_POST[ 'styleId' ] ) && ! empty( $_POST[ 'styleId' ] ) )
  24. {
  25. $intStyleId = (int)$_POST[ 'styleId' ];
  26. setcookie( 'styleId', $intStyleId, time() + 60 * 60 * 24 );
  27. }
  28. elseif( isset( $_COOKIE[ 'styleId' ] ) )
  29. {
  30. $intStyleId = (int)$_COOKIE[ 'styleId' ];
  31. }
  32. else
  33. {
  34. $intStyleId = 1;
  35. }
  36.  
  37. }
  38.  
  39. echo 'Aktualny styl: ' . $intStyleId;
  40.  
  41. ?>
  42. <link rel="stylesheet" type="text/css" href="style_<?php echo $intStyleId; ?>.css" />
  43.  
  44.  
  45. <form id="styeSelect" action="#" method="post">
  46. <select name="styleId">
  47. <option value="1">Red</option>
  48. <option value="2">Green</option>
  49. <option value="3">Blue</option>
  50. </select>
  51. <input type="submit" name="submit" value="Change style" />
  52. </form>
  53. </body>
  54. </html>

(IMG:http://forum.php.pl/uwaga.gif)
~mike_mech
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 7.10.2025 - 08:49