Current location: Hot Scripts Forums » Programming Languages » PHP » PHP & sessions, why won't it work?


PHP & sessions, why won't it work?

Reply
  #1 (permalink)  
Old 10-04-03, 02:41 PM
TinnyFusion TinnyFusion is offline
New Member
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question PHP & sessions, why won't it work?

Hi all, I have made a simple username & password login script that uses sessions.
The problem is that it just does not do anything at all....
On my system I can not login at all, it just seems to clear the username & password form no matter if the username & password are correct or not.

Please could someone advise me of what I need to change either in my php.ini or my httpd.conf so that I can get sessions working ok.

Here is the code:

config.php
PHP Code:

<?

# Admin Panel User Name
$uname "admin";
# Admin Panel Password
$pword "admin";
?>
index.php
PHP Code:

<? 

require ("config.php");
session_start();
if ((!
$username) || (!$password)) {
echo 
'<form name=login method=post action="">
user:<input type=text name=username><br>
pass:<input type=text name=password><br>
<input type=submit value=go>
</form>'
;
}
else {
if (
$username=="$uname")  {
session_register("username"); 
session_register("password"); 
echo 
"user is $uname, and password is $pword
<br> <a href=\"?m=1\" >unreg</a>"
;
}
else echo 
"nope";
}
if (
$m==1) {
session_unregister("username"); 
session_unregister("password"); 
}
?>
If it helps here is a bit of a run down to what I have installed at the moment:
Apache Server v2.0.47
ActivePerl v5.8.0
PHP v4.3.2
MySQL v4.0.15
phpMyAdmin v2.5.3
All running from Windows XP pro

Also, I have tried quite a lot of scripts to add a 'members' section to my website and all are the same, I simply can not login to any of them so I am guessing that its something to do with my server setup.

Thank you in advance, TinnyFusion

(I have added the code as an attachment to this post)
Attached Files
File Type: zip session.zip (1.0 KB, 236 views)

Last edited by TinnyFusion; 10-04-03 at 02:47 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-04-03, 02:51 PM
YourPHPPro's Avatar
YourPHPPro YourPHPPro is offline
Community VIP
 
Join Date: Aug 2003
Posts: 430
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
if ((!$username) || (!$password))
One suggestion I have is to do the following:

PHP Code:

if (!(array_key_exists("username"$_POST)) || !(array_key_exists("password"$_POST))) { 

http://www.php.net/manual/en/reserve...variables.post

The other suggestion I have is to do the following:

Quote:
// Use of $_SESSION is preferred, as of PHP 4.1.0
$_SESSION["zim"] = "An invader from another planet.";
http://www.php.net/session_register
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i work with PHP mail() function darkcarnival PHP 5 08-31-09 06:11 PM
PHP Don't work Henry PHP 4 07-22-03 03:36 AM
$GLOBALS["PHP_SELF"] doesn't work - Why? kevin PHP 7 07-17-03 08:48 AM
how to get my sessions script work with cookies JM007 PHP 1 06-24-03 09:06 AM
php sessions burningr PHP 22 06-12-03 08:07 AM


All times are GMT -5. The time now is 07:01 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.