[PHP-DB] Re: apache, mysql, php4 for windows.

2003-06-20 Thread Cristian MARIN
Are you sure the cookie is set on your machine? What is your IE setting
about what cookie should accept? Because this is generaly the problem

-- 
-
Cristian MARIN - Developer
InterAKT Online (www.interakt.ro)
Tel: +4021 312.53.12
Tel/Fax:  +4021 312.51.91
[EMAIL PROTECTED]
Jerry [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 I have apache, mysql and php4 for windows installed.

 I grabbed all my webapages and mysql databases to my
 pc.  But my login cookies/script fails to work at all.
  It wont let me login.  Is anyone aware of a fix for
 this?

 I am only using a basic login script/cookie that looks
 for a username and password combination in a database.
  If one is found than it updates the database with a
 sid entry and logs a cookie on the users pc.

 Works fine in linux but not under Windows.  Anyone
 come accross this and knows a fix?

 If you would like my code and see what I have please
 ask.  I am not sure if it's really needed though as I
 am sure you guys have come accross it also.

 Thanks!



 http://mobile.yahoo.com.au - Yahoo! Mobile
 - Check  compose your email via SMS on your Telstra or Vodafone mobile.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: apache, mysql, php4 for windows.

2003-06-20 Thread JeRRy

Are you sure the cookie is set on your machine? What
is your IE setting
about what cookie should accept? Because this is
generaly the problem

Okay maybe it's best I post my code here and explain a
bit about it.

--my login code--

?php

error_reporting (E_ALL ^ E_NOTICE);


//Put in your own info for username, password, DB,
[EMAIL PROTECTED], Cookiename,
//the name of this page (currently login.php) and the
name of your subscribe
//or new user page (currently new.php).  I went ahead
and included all the HTML
//so this page should work as is, with only the
changes described above needed
// - Lysander ([EMAIL PROTECTED])

$dblink = mysql_pconnect(localhost,usr,pass);
mysql_select_db(tassie_tipping);

$headers=0; //Make Sure HTML Headers are in place
before the form

//after Authenticating the script automatically sends
the browser to
//the webpage of your choice (note if your page calls
this
//script with ?redirect=foobar.php it will
automatically
//redirect to foobar.php after authenticating.  Set
the default
//redirect page here

if ( !isset($redirect))
   {
 $redirect = tip.php;
   }

if (isset($Username)  isset($Password)) {

  $query = select * from tipping where nickname =
\$Username\ and password = \$Password\;

  if ( !($dbq = mysql_query($query, $dblink))) {
echo Unable to query database.  Please Contact a
href=\[EMAIL PROTECTED]mailto:[EMAIL PROTECTED]/a.\n;
exit;
  }

  $lim = mysql_num_rows( $dbq );

  if ($lim != 1) {

  $headers=1; //HTML headers in place
  echo HTMLHEADTITLELogin
Page/TITLE/HEADBODY;
  echo Bcenterfont color=redInvalid User ID or
Password. Please Try again/BBR/font/center;

  }

  if ($lim == 1) {

//make unique session id and store it in Database
  $timer = md5(time());
  $sid = $Username . + . $timer;
  SetCookie(login,$sid,time()+3600); //Set Cookie
for 30 days
  $query = update tipping set sid=\$timer\ where
nickname=\$Username\;

  if( !($dbq = mysql_query( $query, $dblink))) {
echo Unable to update database.  Please contact
a
href=\[EMAIL PROTECTED]mailto:[EMAIL PROTECTED]/a.\n;
  exit;
  }

  header(Location: $redirect);
  exit;

}

if (isset($login)) {
  $headers=1;
  $sidarray = explode(+, $login);
  $query = select * from tipping where nickname =
\$sidarray[0]\ and sid = \$sidarray[1]\;

  if ( !($dbq = mysql_query($query, $dblink))) {
echo Unable to find database.  Please Contact a
href=\mailto:[EMAIL PROTECTED][EMAIL PROTECTED]/a.\n;
exit;
  }

  if (mysql_num_rows( $dbq ) == 1) {
echo HTMLHEADTITLELogin
Page/TITLE/HEADBODY;
echo centerYou are already logged in as
$sidarray[0].BR;
echo You may logon as another user or simply
begin using our services with your current
session.BR;
echo Click A
Href=\http://www.tassiedemononline.org.au/tiplogin.php\;Here/A
to return to our homepage./center;
  }
}
if ($headers == 0) {
echo  ;
}
}

echo Form Action=\tiplogin.php\ METHOD=POST;
echo H2User Name/H2;
echo Input TYPE=\text\ Name=\Username\
Value=,$Username,;
echo BR;
echo H2Password/H2;
echo Input TYPE=\password\ Name=\Password\;
echo BR;
echo Input Type=\submit\ Value=\Submit\;
echo Input Type=\hidden\ Name=\redirect\
Value=\tip.php\;
echo /FORM;

?

--end--

Okay as you can see in the code there are some
//comments.  Will help explain what each function
does, or what it's meant to do.

A quick overview is that you are shown a login form. 
(no cookies loaded onto the users PC as of yet)  The
user must input a username and password which must
match in the database.  If there is a match the user
is given a cookie on their PC with an expiry period
which than loads onto the next page $redirect which
the $redirect page checks to see if the user still
matches in the database and see's if the cookie (id)
or sid matches with the database.  If matches it
allows you to see the page, if not it says your
session has times out and to try again.

It works fine under my linux machine, no problems. 
But as soon as I tried under windows after I installed
all my programs I needed it failed badly.

What it does under windows is show the form and input
my username and password (does not matter if they are
correct or not because the results are the same) and I
click the submit button and all it does is reload the
form.

What it appears to be doing is not even doing the
mysql query.  (form the looks of it)  It seems to loop
through the page again as if your loading it the first
time.  Either that or my form is not submitting the
data at all.

If I don't enter data on my linux server on the login
I get a error message (which is in the code) but if I
do it on windows it does nothing.  Just loads the form
again.

So I am going to try something new later today and
have the form and the logn process on two different
pages and see what happens.  Not sure if this will do
anything different but I will try.  Anyone got any
suggestions?

My other PHP pages under windows work fine, they query
my mysql database(s) fine and output the results as
they should.  This