Jump to content


Photo

Trouble with session_start();


  • Please log in to reply
13 replies to this topic

#1 PigsHidePies

PigsHidePies
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 08 September 2006 - 09:10 AM

My current problem has to do with session_start();
I am trying to add this to the top of all my pages. I have it working on my login.php page fine. For some reason though on index.php instead of it working I get two of the same messages/links at the very top of the page: "function.session-start"
The rest of the page shows up, but it messes up the structure.
When I click on either of the above comments I get:
"Not Found
The requested URL /function.session-start was not found on this server."
Basically what I am trying to do is check if a user is logged in or not by using: if(isset($_SESSION['validuser'])).
Any help is appreciated.

#2 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 08 September 2006 - 09:12 AM

post code please.

#3 PigsHidePies

PigsHidePies
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 08 September 2006 - 09:33 AM

<?php
session_start();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



<html>

<head>

	<title>help me ahhh</title>

	

<link rel=stylesheet href="style.css" type="text/css">



</head>







<body>



<div id="shaper">






<div id="headerholder">

<div id="leftheader">

<img src="header.jpg" border="0"></img>

</div>

<div id="rightheader">


<?php
if (!isset($_SESSION['valid_user']))
{ 
echo '<form name="input" action="login.php"

method="post">

username

<input type="text" name="username" maxlength=12 class="textbox">

<br />



password

<input type="password" name="password" maxlength=12 class="textbox">

<br />

<input type="submit" value="login" class="submit">

</form>';
}
?>

...more html...
</body>
</html>


#4 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 08 September 2006 - 09:39 AM

can you also post the full error message please?

(view the page source if necessary)

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 September 2006 - 09:40 AM

might be the way you format html code and white spaces



<?php session_start(); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>

<title>help me ahhh</title>

	
<link rel=stylesheet href="style.css" type="text/css">

</head>

<body>

<div id="shaper">

<div id="headerholder">

<div id="leftheader">

<img src="header.jpg" border="0"></img>

</div>

<div id="rightheader">


<?php

if (!isset($_SESSION['valid_user']))
{
?>
 
<form name="input" action="login.php" method="POST">

username

<input type="text" name="username" maxlength=12 class="textbox">

<br>

password

<input type="password" name="password" maxlength=12 class="textbox">

<br>

<input type="submit" value="login" class="submit">

</form>';

<?}?>
...more html...
</body>
</html>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 08 September 2006 - 09:40 AM

redarrow - that won't make any difference, and may well infact break it altogether..

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 September 2006 - 09:42 AM

rubbish correct way to format a form ok.

how brake it?
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 PigsHidePies

PigsHidePies
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 08 September 2006 - 09:48 AM

Still not working,heres the warning messages:



<br />
<b>Warning</b>:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /var/www/index.php:1) in <b>/var/www/index.php</b> on line <b>1</b><br />
<br />
<b>Warning</b>:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /var/www/index.php:1) in <b>/var/www/index.php</b> on line <b>1</b><br />


#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 September 2006 - 09:51 AM

make sure there are no white spaces

goto the end of every php?> and press delete untill reach > ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 PigsHidePies

PigsHidePies
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 08 September 2006 - 09:54 AM

that was it, there was a single space before the <?php line...sorry for the trouble guys but thanks a lot for the help.

#11 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 September 2006 - 09:55 AM

no problam mate no problam anytime.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#12 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 08 September 2006 - 09:56 AM

rubbish correct way to format a form ok.

how brake it?

what if short tags are off? ;)

#13 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 September 2006 - 09:59 AM

then turn them on lol

or use <?php php?>

ok brains lol
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#14 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 08 September 2006 - 11:00 AM

php?> is not a valid closing tag, fyi :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users