session - PHP values not retrieving from other page -


i have page working on sort of game. page page passing user name this

index:

<form method="get" action="start.php">     <label> name: </label>     <input type="text" name="username"><br>     <input type="submit"> </form> 

where retrieve name on second page this:

<?php   session_start();   $_session['username'] = $_get['username']; ?> 

-

  <?php   session_start();   if(isset($_session['username'])){      echo "welcome: " . $_session['username'];   }    else{                       echo "name unknown";   }  ?> 

and on third:

    <p>       <?php          session_start();         echo $_session['username']       ?>     </p> 

and code working fine. making if statement which, when ever don't enter name, won't continue next page. added code first page , working first page.

<?php   session_start();   $_session['username'] = $_get['username'];   if($_session['username'] != "")   {     header("location: start.php");   } ?> 

so after adding this, won't go further unless enter name. doing reason don't know yet , couldn't find, $_session['username'] = $_get['username']; isn't working , names not passed through

this link if play: http://i333180.iris.fhict.nl/site (not finished yet)

these problems:

1- don't need use more 1 session_start() in file. 2- have closed php tag in second code , countinued php coding. 3- before session_start(), must not send header or echo anything. in 3rd code, have echoed

tag before session_start(). 4- same session_start(), must not send header or echo before calling header function. sure in 4th page, not have echoed before header().


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -