I followed a tutorial on http://www.phpeasystep.com/workshopview.php?id=6 and I think it's not working properly for me. When I try to start the session in my sidebar thing it won't actually start somehow :S

<div id="sidebar">
<h2>[<a href="?page=home">Samppa's page</a>]</h2>
<h3>&nbsp;Main menu</h3>
<ul class="menu">
<li><a href="?page=about"> >> About</a></li>
<li><a href="?page=projects"> >> Projects</a></li>
<li><a href="?page=photos"> >> Photos</a></li>
<li><a href="?page=lab"> >> THE testing lab</a></li>
</ul>

<h3>&nbsp;Anything else</h3>
<ul class="menu">
<li>Email me!<a href="mailto:samppa.l@hotmail.com"><br /><img src="mail.png" width="210" height="210" /></a></li>
<li><br />Have a question?<a href=""><br /><br /><img src="question.png" width="210" height="210" /></a></li>
</ul>

<h3>&nbsp;Login</h3>
<ul class="menu">
<br />
<?
session_start();
echo $_SESSION['myusername'];
?>
<form name="form1" method="post" action="checklogin.php">
<li>Username: <input name="myusername" type="text" id="myusername" /></li>
<br />
<li>Password: <input name="mypassword" type="text" id="mypassword" />
<br />
<br />
<li><input type="submit" name="Submit" value="Login" /></li>
</ul>

</div>

It won't echo the username I don't understand why, and if I try with <?php and ?> instead of <? ?> I get an error, I am really noob in this please help, and also look the link I gave then you get idea.

I see 2 things:

1. in the 2nd line try to remove the '
2. You never close the form </form>

Still won't work even simple echo doesn't work in that <? ?> but if I do <?php it works.. but if I put session start there I get error

better use echo statement in check login.php
Welcome <?php echo $_POST; ?>!<br />i hope it will work

One thing I can see is that your session_start() should be the first thing on the page, as nothing can be echoed or written to the browser before the session actually starts.

plus, close your form tag

As BrianDickson said session_start() should be the first line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.