By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

probelm with sessions and form

P: n/a
I am not what I am doing wrong. When I enter the log-in info and press
submit, I keep getting the login section repeatedly (I never get
It works fine if I delete the php session lines.
Here is the script:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html;


if ($username != 'user' or $password != 'pass')
<form action="self.php" method="post">
<input name="username" type="text" id="username" value="user name">
<input name="password" type="password" id="password" value="password">
<input type="submit" name="Submit" value="Submit">
<? ;
echo "This section includes the rest of the page that shows up if the
correct log-in info is submitted";


Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
hi , dan
of course it will not work fine , but we can fix this
to work with session you have to do some steps i'll list here some
important points and you will make the validation in your server
1- Are the sessions working ?
-check php.ini file in you system directory usually (C:\windows) you
will find some thing like this
session.save_path = "C:/php/session_directory" so session_directory is
the location where the session are stored on the server
-check session_directory is it there and your script really write the
session there (in session_directory).
2-now let us disscuss how you check these data , you do like this :
-------------------your code------------------
if ($username != 'user' or $password != 'pass')
-------------------your code------------------
you first need to check if the sessions are registered or not by using
session_is_registered() method, to
do so like this :
--------------------------my code---------------------
if (!(session_is_registered("username") &&
--------------------------my code---------------------
so (session_is_registered("your_session_var") is the function that give
you ability to check these information......
3-but your code is need more maintinance if you want to get the value
of the sessions you can do somthing like this:
if ($_SESSION['username']!= 'user name' || $_SESSION['username']!=
$_SESSION is PHP array that give you the accessability to your session
i, hope this will help you and tell me about the result.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.