473,788 Members | 2,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("$userdat a", "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='authent icationtest.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='authent icationtest.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!
Jul 16 '05 #1
1 2387

Oh I see! Thanks a lot! It works great now!
Jul 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
2594
by: Joshua Ginsberg | last post by:
Is there any plan to include inline conditionals in Python? For example: def isNegative(x): return x < 0 ? True : False Thanks! -jag --
1
1988
by: Paul Dale | last post by:
Hi All, I know that several of you will probably want to reply "you should write a parser", and I may. For that matter any tips on theory in that direction would be appreciated. However, if you would indulge me in my regex question I would also be most grateful. I'm writing an edi parser and to be in compliance with the specification
3
1442
by: steven | last post by:
Is it possible to combine conditionals to call out data? I have a list of records that include a date. I can call out all dates after the date after tomorrow: IIf(Date()+1)<,...,... And I can call dates before next week: IIf(< Date()+7,...,... But I'd like to isolate those that fall between the day after tomorrow and next week. I was thinking that this would work, but it doesn't:
4
2026
by: Leon Lambert | last post by:
I would appreciate it if someone could help me understand NaN handling with respect to conditionals in IL code. I am playing with a small IL interpreter and having a little problem with it. Following is a small piece of C# code that gets compiled by VS2005 to simulate my problem. static void Main(string args) { Double db1 = 1.0; Double db2 = Double.NaN; if (db1 <= db2) db2 = 1.0;
11
1800
by: .Net Sports | last post by:
I need to convert some C# ?Conditionals over to vb.net (most likely in vb.net using If..Then statements), but the C#2VBNETconverter by KamalPatel isn't converting them: string PurchaseType = (Convert.ToString(drwData) == "True") ? "ID" : "PID"; XmlNodeList Selections = xdcData.GetElementsByTagName((X == 0) ? "Highlight" : "Selection");
5
2166
by: Hul Tytus | last post by:
comp.lang.c c programs & shell conditionals How is a unix shell script made to respond to the value returned by a program compiled from c code? The shell script below is my current effort, which doesn't work. The c code shows what was used to generate a.out, seen in the shell script. The value returned was varied from 0 to 1 for testing.
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.