Help...Am a complete newbie to programming so my code is prolly quite long. Am trying to verify a users details entered into a login form against details stored in an existing flat file.
No matter what I input, I get "not registered", even if it does match.
What have I done wrong? I have spent 3 LOOng afternoons trying to nut this out..now am going nuts....
<?php
if ($_POST['submit']=="submit")
{
$errormessage = "";
if (empty($_POST['userName']) ||empty($_POST['password']))
{
$errormessage = "<p>Please enter a user name and password</p>";
}
else
{
$userName=trim($_POST['userName']);
$password=trim($_POST['password']);
// check user name and password
$nameFlag=false;
$passwordFlag=false;
$fp = fopen($_SERVER['DOCUMENT_ROOT']."/toys/users.txt","r" );
while (!feof($fp))
{
$line=fgets($fp,100);
($userName== $line? $nameFlag=true : $nameFlag=false);
($password==$line? $passwordFlag=true : $passwordFlag=false);
}
fclose($fp);
if($nameFlag && $passwordFlag==true)
{
$foundFlag= true;
}
else
{
$foundFlag=false;
}
($foundFlag==true?$welcome= "Welcome ".$userName." you are now logged in":$sorry= "Sorry you are not registered");
}
}
?>
// my html form below
<form method="post" action="<?=$_SERVER['PHP_SELF']?>" >
<fieldset class="outline">
<h3>Registered customers</h3>
<label>User Name:</label>
<input type="text" class="login" value="" name="userName" id="userName" />
<label>Password:</label>
<input type="text" class="login" value="" name="password" id="password"/>
<br />
<br />
<input type="submit" value="submit" name="submit" id="submit"/>
<br />
<?=$errormessage?>
<br />
</fieldset>
</form>
Onclick problem in Firefox
Hi, I am using a <label onclick="myfunction(this)"></label>. It doesn't seem to trigger in Firefox but works fine with ie. Does anyone know why?Thanks
problem with php server update from mid 2009
Hi,I have this navigation menu on 2 websites which used to work just fine. After a recent update to the php server, the menu stopped working properly. It still loads the pages but the highlighted
How to generate a random array of integers subject to a certain constraint
I am writing a program that asks the user to enter an integer N and then generates a random array of integers of size 2^N, each of whose entries range from 1 to N+1. The final random array, however,
max function question
Hi All
Taking an HTML form and a PHP program and making it into one working file.
Hello, So I would like to display everything INSIDE a specific directory. In other words, I would like to display all file name's inside all subfolders in a specific directory. (NOT the subfolder
finding key position of specified value in multi-dimensional array
Code: $openedfile = fopen($tfc_file4, "r");$rc = 1;while(!feof($openedfile)){$rc++;$hold[$rc] = explode("|" , trim(fgets($openedfile)));}fclose($openedfile);How can I loop through
Grouping and sorting results
Please help with this query.I have 2 tables in a database, countires and cities. states looks like thiscountriesid -----------country1 ------------uk2 ------------us3 ------------japancitiesid
POST into Array problem
Hi Chaps,I have a repeat region, displaying rows of data: jobid, fromtable, translatorchargeIn each row there is an input field to enter a cost for each job 'charge'.//INPUT - TRANSLATOR CHARGECode:
INSERT data problem!
After having an string with apostrophes ', double quotes " or any other special characters, successfully escaped through one of themany php functions availables to escape, what other
Inserting into MySQL Newbie
Hi ive got a slight problem where ive made a simple web form where the customer inserts the ammount of tickets and then enters their personal details... then this form does the post method and it then