probelm with sessions and form

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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";


Re: probelm with sessions and form

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.

Site Timeline