OK, a few things - and I jsut work up and am on my first coffee, so I hope this all makes sense:
1) newsession file
you don't really need an included file for this, just call session_start() at start of each page.
getting the session id into it isn't necessary
you are assigning['u_id'] to an uninitialized variable, and, again, this shouldn't be needed.
when a session is started like this it will already hold any information previously put into it by you.
2) signup file
this also doesn't need to be it's own file, but the form can be alternate content on any page for 'not logged in' status, really. (of course only needed on any page login is required for)
if you have a 'isLoggedIn()' type function you call on each page that does something like the following:
checks if a login has been posted, and if so, processes it
- this can also spit out any errors on signup processing
- on successful login or creation, it logs teh user in (puts their info into session)
else checks if a user is trying to log out (ie, $_GET['logout'] == true, or however you provide logout) and if they are, logs them out (ie, clears relevant session values)
checks if a user is logged in, and if so, returns true.
if not, displays the form and returns false.
- there should probably be 2 forms to this part - a returning login and a creation.
then you can call this function, and if it returns true, you can show page content, and if not, it's already spat out the forms
of course, this is because your signup form is short, if you want a specific page for signing up, you could put it elsewhere
your user insertion query doesn't match up fields and values properly - the 'pass' is not in teh fields and not as a value
you should probably check if a username exists before inserting a new user to prevent duplicate username entries.
after running insert query, run a select filtering my mysql_insert_id() to get teh newly created user and put them into _session var to store them as logged in
loginck file :
$email=mysql_real_escape_string($email);
should be
$email=mysql_real_escape_string($_POST['email']);
(same for pass)
and then the if check isn't needed, if you get a resulting row, then you already know the username and password combo works
you store the resulting row into $_SESSION, or at least the relevant info, this is what you check to see if a user is logged in, and unset/clear if they log out.
I think that's pretty much everything, if my half awake brain missed anything, lemme know 😛