Nie wiem jak połączyć ob_start i session start. Mam kod stronki (na początku jest oczywiście formularz logowania):
<?php if (!ereg('[[:upper:]]+[a-z]+[^0-9 ]', $_POST['uzyt']) || !eregi('^[a-zA-z_]+@[a-zA-z0-9\-]+\.[a-zA-z0-9\-\.]+$', $_POST['email'])) { echo '<br/>'; exit; } else { $link = mysql_connect("tajne", "tajne", "tajne"); mysql_select_db ("tajne"); mysql_query("INSERT INTO odwiedza (imie, mail) values ('".$_POST['uzyt']."','".$_POST['email']."')"); require_once ("tabs.php"); ?> <html> <head> <?php tabs_header(); ?> </head> <body> <?php tabs_start(); ?> <?php tab("Temat pierwszej zakładki"); ?> Tekst pierwszej zakładki. <?php tab("Temat drugiej zakładki"); ?> Tekst drugiej zakładki. <?php tabs_end();?> </body> </html>
Kod tabs.php to:
?php $tabs = array(); function tabs_header() { ?> <style type="text/css"> .tab { background-image: url(tlo.png); background-repeat: repeat; border-bottom: 1px solid black; text-align: center; font-family: arial, verdana; } .tab-active { background-image: url(tlo.png); background-repeat: repeat; border-left: 1px solid black; border-top: 1px solid black; border-right: 1px solid black; text-align: center; font-family: arial, verdana; font-weight: bold; } .tab-content { background-image: url(tlo.png); background-repeat: repeat; padding: 5px; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black; } </style> <?php } function tabs_start() { ob_start(); } function endtab() { global $tabs; $_SESSION['zmienna sesji']=$_POST['uzyt']; $text = ob_get_clean(); $tabs[ count( $tabs ) - 1 ][ 'text' ] = $text; ob_start() } function tab( $title ) { global $tabs; if ( count( $tabs ) > 0 ) endtab(); $tabs []= array( title => $title, text => "" ); } function tabs_end() { global $tabs; endtab(); ob_end_clean(); $index = 0; if ( $_GET['tabindex'] ) $index = $_GET['tabindex']; ?> <table width="100%" cellspacing="0" cellpadding="0"> <tr> <?php $baseuri = $_SERVER['REQUEST_URI']; $baseuri = preg_replace( "/\?.*$/", "", $baseuri ); $curindex = 0; foreach( $tabs as $tab ) { $class = "tab"; if ( $index == $curindex ) $class ="tab-active"; ?> <td class="<?php echo($class); ?>"> <a href="<?php echo( $baseuri."?tabindex=".$curindex ); ?>"> <?php echo( $tab['title'] ); ?> </a> <?php $curindex += 1; } ?> </tr> <?php echo( $tabs[$index ]['text'] ); ?> </table> <?php } ?>
To jest oczywiście już stary, znany ludziom przykład książkowy. Zacząłem studiować podręcznik na php.net ale nie pomógł mi on nic.
