Conditionals Help!

This is a discussion on Conditionals Help! within the PHP Language forums, part of the PHP Programming Forums category; Ok, I'm having some trouble with conditionals, for some reason PHP is screwing them up. First off, here is ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-28-2003
FHuang
 
Posts: n/a
Default Conditionals Help!

Ok, I'm having some trouble with conditionals, for some reason PHP is screwing them up.
First off, here is the code:

<?php
$username = "fred";
$userdata = "./$username.txt";
$fp = fopen("$userdata", "r", 1);
$origpass = fread($fp, 5);
if($passcount = 1)
{
if($pass = $origpass)
{
echo "Welcome to the Members' Only Part of the Site!";
}
else
{
echo "Sorry, wrong password, please try again:";
echo "<form method='post' action='authenticationtest.php'>";
echo "<input name='pass' type='text'>";
echo "<input name='passcount' type='hidden' value='1'>";
echo "<input type='submit'>";
echo "</form>";
}
}
else
{
echo "Please input your password below:";
echo "<form method='post' action='authenticationtest.php'>";
echo "<input name='pass' type='text'>";
echo "<input name='passcount' type='hidden' value='1'>";
echo "<input type='submit'>";
echo "</form>";
}
fclose($fp);
?>

Its a relatively simple authentication script. It reads a password from a text file and compares it to the
value sent previously. The problem seems to be one of two things:

The first, is that PHP takes the wrong else statement, it goes from the first if (about $passcount) and then
goes directly to the else statement with the sorry form. It never goes down to the correct else!

Secondly, it seems that for some reason after a successful login, it will forevermore only display welcome.
I don't have any cookies set, nor sessions, so then how do I get it to logout? Need some help with that.

Thanks for any help in this!
Reply With Quote
  #2 (permalink)  
Old 06-29-2003
FHuang
 
Posts: n/a
Default Re: Conditionals Help!


Oh I see! Thanks a lot! It works great now!
Reply With Quote
Reply


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

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



All times are GMT +1. The time now is 04:18 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0