css - Simple PHP Sessions Error -


i have discovered problem want know why issue. had 2 pages form1.php started session on page , hit submit. had link session2.php started session , able pull information form1.php. learning sessions , simple exercise learn session can do.

here lies issue, had stylesheet link in head , had blank href href="#" , when there session2.php not start session form1.php , grab info form. without href="#" in style tag worked fine, , worked fine if fake styletag href="something.css" href="" doesn't work either.

why this? have in because template made workflow, maybe cant include css link in template anymore prevent future issues.

you can see site working here, if haven't explained myself.

form1.php

<?php session_start(); $_session['name'] = $username; ?>  <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html>  <head> <title></title> <!--//css stylesheets//--> <link rel="stylesheet" href="#" type="text/css"> </head>  <body> <a href="sessions2.php">go session 2</a> <!--form stuff in here--> </body 

session2.php

<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en"    "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html>  <head> <title></title> </head>  <body>    <?php  session_start();   $username = $_session['name'];   echo $username;     ?>   </body> </html> 

your second page needs this:

<?php     session_start(); ?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en"    "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html>     <head>        <title></title>     </head>     <body>     <?php         $username = $_session['name'];         echo $username;     ?>     </body> </html> 

note session_start() must appear before content printed screen.

per note on session_start php manual page:

note: use cookie-based sessions, session_start() must called before outputing browser.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -