Jump to content


Photo

Why doesn't this work?! :\


  • Please log in to reply
57 replies to this topic

#21 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 01 August 2006 - 04:12 PM

And the first thing is going to be to test to make sure the script is reading anything at all.  It might not be matching the criteria.  Put
echo "test1";
echo "test"2;
echo "test3";
at different interval's to see where the script is running and where it's not, if at all.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#22 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 01 August 2006 - 04:12 PM

Businessman what king arthur ment was it doesnt matter how much space you have between <?php and session_start();, but what does matter is the space before the opening <?php tag. Any whitespace after <?php is not outputted to the browser, unless you are echo/print'ing it.

#23 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 01 August 2006 - 04:14 PM

oh ok, I didn't know that, thanks for telling me

<?php
session_start(); //start a sessions :D
echo "test1";
$username = $_POST["username"]; //get the username from the form, as $username
$password = md5($_POST["password"]); //get the password from the form in md5

$users = mysql_connect("localhost", "lov3dco_users", "test");
    if(!$users) {
          echo "<p>Sorry! We could not log you in at this time. Please Try again later!</p>";
          exit();
        }
echo "test3";
mysql_select_db("lov3dco_users");  //select what database to use
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$recieve = "SELECT * FROM users WHERE username =  '$username' AND password = '$password';";
$query = mysql_query($recieve) or die("Unable to peform query - " . mysql_error()); //do the query
echo "test4";
if($rows = mysql_num_rows($query)){
    $_SESSION['password'] = $password; //store the users password in a sesions var
    $_SESSION['username'] = $username; //store the username in a session var
$page = "index.php";    
echo "test5";
header('Location: ' . $page);
}else {
echo "test6";
    session_destroy(); 
}


?>

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#24 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 01 August 2006 - 04:20 PM

and how did you know my name was joyel?

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#25 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 01 August 2006 - 04:32 PM

If the user "test" does not exist in the database with password "test" encoded with md5 then yes you will get a blank page as it will just get to the session_destroy() and the end of the script.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#26 SilverNova

SilverNova
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 01 August 2006 - 04:35 PM

http://lov3d.com/test.htm

They all show.. :\ I thought test 2 didnt but realised you went 1,3,4.. :P

See your sig - I had a brief look around  :)

#27 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 01 August 2006 - 04:37 PM

test1test3test4test5
Warning: Cannot modify header information - headers already sent by (output started at /home/lov3dco/public_html/test.php:3) in /home/lov3dco/public_html/test.php on line 24

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#28 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 01 August 2006 - 04:38 PM

As I said earlier there "something" above session_start();
also if all the tests are showing something isn't working right.
make sure
<?php
session_start();
?>
the <?php make sure it's at the top wall of the page, with nothing else above it.not html, or anything.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#29 SilverNova

SilverNova
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 01 August 2006 - 04:41 PM

yeah it is encoded with md5 in the table

the password field for the row is 098f6bcd4621d373cade4e832627b4f6.. which = "test"
there are other fields which just have blank entries so this shouldn't matter? like "email" for their email address etc.

#30 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 01 August 2006 - 04:41 PM

Something is being outputted on line 3 in test.php. As this where PHP has detected where the output has started:

Warning: Cannot modify header information - headers already sent by (output started at /home/lov3dco/public_html/test.php:3) in /home/lov3dco/public_html/test.php on line 24

Note the bit in bold above. Thats the important bit you want to read.

#31 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 01 August 2006 - 04:45 PM

what about something in php.ini or htaccess that is making something output before the php page is even called from the server, that could be causing it.???

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#32 SilverNova

SilverNova
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 01 August 2006 - 04:45 PM

Posted Image

That's what I have.

Also, why can't i see this warning message?!!!? I'm using FF, all I get after login is:

"test1test3test4test6" on the test.php page :\ ???

#33 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 01 August 2006 - 04:48 PM

browsers handling sessions differently I never heard of it, it has something to do with php.ini I would guess, for now give us your entire php.ini file, and anything you might have in your .htaccess page.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#34 SilverNova

SilverNova
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 01 August 2006 - 04:49 PM

I've never had to use php.ini before, all I know is that it's a global set of events etc

You're welcome to have a look - http://lov3d.com/php.ini

I presume it's in the right place, I took it from php.net after being told I should use (well, open) it. I don't seem to have a php.ini file elsewhere on my server unless i'm not looking in the right places.

It's not the .htaccess :\ - it's blank at the moment

#35 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 01 August 2006 - 04:49 PM

maybe sometimes you can't have anything next to session_start();
good practice, try putting it in it's own section
<?php
session_start();
?>
<?php
everything else here

Try that, but I don't understand this, the reason itw as coming up blank is the username and password don't match, or one of the queries is wrong, I don't see what else can be causing this.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#36 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 01 August 2006 - 04:51 PM

session.cookie_lifetime = 0
increase that to 4 hours will allow the cookie to work after the browser is shut down.  There is nothing wrong with php.ini what about .htaccess
THe thing I would suggest is give me a little while if no one else can help.
I am leaving for like 2 hours.  Be back later.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#37 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 01 August 2006 - 04:52 PM

The error isnt to do with the session anymore. But to do with the header redirect on line 24. From looking at the sreenie, you have output on line 3 - echo "testl"; Remove that otherwise the header function wont work (on line 24). Pleae read the error message correctly and that you understand it.

#38 SilverNova

SilverNova
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 01 August 2006 - 04:52 PM

I changed it to:

<?php
session_start();
?>
<?php
echo "test1";
$username = $_POST["username"]; //get the username from the form, as $username
$password = md5($_POST["password"]); //get the password from the form in md5

..etc.

Still nothing..

#39 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 01 August 2006 - 04:53 PM

try what wildteen said for now, remove test1, the echo at the top, see if that fixes that part, then we can concentrate on the part below that to get the query to work.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#40 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 01 August 2006 - 04:54 PM

he was right, the error is changing based on teh location, I don't know the technicalities of how far it has to be, but I guess don't use echo's too close to the thing, just remove test1

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users