views:

56

answers:

2

I was following a tutorial I found on how to create a simple login using sessions and a database. I followed it to the T (with the exception of tidying up all of the code because theirs was a mess and I'm OCD like that).

I get no errors at all on the page, it just comes up with a blank screen and I can't work out for the life of me why it's doing. I've been trying to get it working for the best part of about 3 hours.

There are 4 files:

  1. index.php - Contains the form for the login script
  2. login.php - Where the form data is processed, which is "require_once"'d into the index.php page at the very start.
  3. config.php - Database connection info
  4. cpanel.php - Where I want the user to be sent once they logged in

And here are those 4 files in action (although I guess they're not in action since they don't actually work!):

index.php login.php config.php cpanel.php

And here's the tutorial I used.

Lastly here's a link to the original (non-source) index.php file

Hope you guys can help, it's driving me crazy now.

A: 

You should try error_reporting(E_ALL); for additional Error output. Check all POST Variables with an echo() / var_dump(), Check the Ifs also with echo() and make sure thats everything is OK. The echo for $error is doubled.

Additional you should not use the Location Element on the Header with an relative Path.

Michele
why can't you use relative paths in `header("location:")`? I don't think that's right.
Thomas Clayson
Because the HTTP1.1 Spec for Location says so, the most Clients accept it relative but its not HTTP1.1 Spec conform see: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30
Michele
I'll look into it further tomorrow, nearly finished work now so I can finally put it down. Thanks for the advice, any more suggestions are extremely welcome!
Chrish
+1  A: 

Just change

if($jackin) {

to

if(isset($jackin)) { 

in login.php file

Also put ini_set('short_open_tag',1)

in your cpanel.php file if short_open_tag is disabled in php.ini

Yogesh
This worked thanks! However ini_set('short_open_tag',1) gave me an error, taking it out fixed it. I changed the <? tags to <?php, which I prefer to use anyway.
Chrish