Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Neither get nor post nor session data available

Status
Not open for further replies.

spitzmuller

Programmer
May 7, 2004
98
CH
Hi there

I have Apache, PHP 5, MySQl 4 up and - as it seems - running smoothly on my desktop computer.

Now I have created a classic login-page using Dreamweaver 8: My problem is that when I submit the login-page, i cannot access the post-data on the called page. i.e. the $_POST variable is empty!! and so are $_SESSION and $_GET.

Is there some setting in the php.ini that I missed or any other setting that needs to be taken care of to make this work???? I'm desperate!

Thanks in advance to this great forum
 
Have you turned on error reporting in the php.ini, by default you get no output to the page these days, maybe you have a typo but it wont tell you that unless you have display_errors = On


______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Yeah, display_errors is on. I echoed $_POST etc. on the page I load, an there's nothing in there

 
do you get anything at all ? say if you just add
echo "test";

do you get ony output at all ?

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Yeah, I get output.

I found out that if i send the form data via the get method, it works. But I still don't get anything in $_POST and $_SESSION. The Cookie with the sessionID resides in the browser but I doesn't seem to be sent along with another request. the cookie validity path is "\" which should be ok.

Any idea?
 
racking my brains, I had this a couple of weeks ago but mine was due to typos, and display_errors set to off, don't think I found anything else odd.

You havent added aything to httpd.conf have you, php5 doesnt need the AddType...blah


______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Ok, Get and Post do work after all, I had something messed up in my code.

Now I have this small example, where I try to get the Session by using the cookie set on the browser. Only it doesn't work. If I encode PHPSESSID=... in the url, it works, though. There must be something wrong with the cookie interpretation, mustn't there? Any Idea?


<?php
session_start();
if (!session_is_registered('count')) {
session_register('count');
$_SESSION['count'] = 1;
} else {
$_SESSION['count']++;
}
?>

<p>
Hello visitor, you have seen this page <?php echo $_SESSION['count']; ?> times.
</p>

<p>
To continue, <a href="nextpage.php">click
here</a>.
</p>
 
Is the session cookie being set in your browser?

I do not know if this is in any way related to your problem, but you should not be using session_register() in your code. The PHP online manual entry for session_register() states, "If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered(), and session_unregister()."

So your script should read something like:
Code:
<?php
session_start();
if (! isset ($_SESSION['count']))
{
    $_SESSION['count'] = 1;
}
else
{
    $_SESSION['count']++;
}
?>

<p>
Hello visitor, you have seen this page <?php echo $_SESSION['count']; ?> times.
</p>

<p>
To continue, <a href="nextpage.php">click
here</a>.
</p>



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks for that, but it doesn't change a thing.

By the way. If I set session.use_trans_sid = 1 in the php.ini, it works as well. It just doesn't work if i rely solely on cookies. The sessionID-cookie is recieved by the browser as well, so there can only be two possible reasons for it not to work.

1) the cookie doesn't get sent back
2) PHP won't evaluate the cookie being sent back

Any suggestions? Do you know a way to extract the whole header info from a request made by the browser?

Thanks a ton so far Simon
 
Well here it comes:

1) The cookie does get sent back
2) PHP wouldn't evaluate it because the session.cookie_path needed to be / instead of \ !

Which I thought to be reasonable since I use Windows. Anyway thanks for helping me out, it's been great to talk to you.

C U Simon
 
Yeah, that's something of a problem.

The backslash character is used by PHP as an escape character. You see it used in such strings as "\n" (newline), "\r\n" (carriage return newline) and "\t" (tab).

The problem is that if you have a string like "c:\windows\system32" in a script, PHP will interpret the string as "c:{escape-w}indows{escape-s}ystem32". The workaround in PHP is to use the forward slash for path separation, regardless of OS. After all, PHP is platform agnostic and only Win32 uses backslash for this purpose.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top