Forum Moderators: coopster
index.php
<?
session_start;
session_register("Ustat");
if ($Ustat!= 1){
THE Form where login name and password are entered
/* when i submit this form it goes to verify.php */
}
else { Welcome message and Logout link }
?>
verify.php
<?
if username and password are present in database then
session_start();
$Ustat=1;
session_register("Ustat");
header("location: ./index.php");
?>
What am i doing wrong why doesn't this work Can anyone help
Thank you
Also just a quick note. RFC's say you are suppose to do a RQDN in a "Location" header. Relitive urls (like your example) work in every browser that I've checked but it's not spec...
Also I have had problems with sessions when using Stronghold (A commercial line of Apache). Not sure if that's your problem but thought I'd mention since I had many a late night until I figured that one out.
This should work for you:
index.php
<?
session_start;
if ($_SESSION['Ustat']!= 1){
THE Form where login name and password are entered
/* when i submit this form it goes to verify.php */
}
else { Welcome message and Logout link }
?>
verify.php
<?
if username and password are present in database then
session_start();
$_SESSION['Ustat']=1;
header("location: ./index.php");
?>
<? phpinfo();?>
That will tell you your PHP version and lots of other good informatin about your PHP installation.
Regarding the URL it's because of your redirect. PHP didn't realize what you were doing and could not rewrite the URL. Your should change:
header("location: ./index.php");
to
header("Location: [${_SERVER['HTTP_HOST']}...]
.dirname($_SERVER['PHP_SELF']).
"/index.php?"
.SID);
The first part is what I talked about before. It just gives you your FQDN. The last part "SID" is a define. If PHP sees that cookies are off it will be populated with "PHPSESSID=XXXXX" or whatever it should be. If cookies are on the SID I believe is simply blank. That way you will not loose the session.