LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-01-2005, 02:26 AM   #1
Erhnam
Member
 
Registered: Jan 2005
Posts: 54

Rep: Reputation: 15
php, else function not working.


I created a script:

<?
// Variabellen declaren
$user = ($_POST['username']);
$pass = ($_POST['password']);
$servername = ($_POST['server']);
$autharray = file("/control-panel/passwd/passwd.$servername");

// Check de wachtwoorden met het Perl script of what ever!
for ($x = 0; $x < count($autharray); $x++)
{
if (eregi("^$user:", $autharray[$x]))
{
$passwd = explode(":", $autharray[$x]);
$salt = substr($passwd[1],0,11);
$cryptpw = crypt($pass,$salt);
if ($cryptpw == $passwd[1])
{
// Succesvol ingelogged dus maken we een session aan!
echo "<br><p align='center'>Username found on: $_POST[server]</p>";
echo "<br><p align='center'>Starting connection: $_SESSION[user]... Moment Please.....</p>";
$_SESSION['user'] = $user;
$_SESSION['server'] = $servername;
if ( $_SESSION[user] == "admin" ) {
echo" <META HTTP-EQUIV='Refresh' CONTENT='1; URL=admin_overview.php'> ";
} else {
echo" <META HTTP-EQUIV='Refresh' CONTENT='1; URL=client_control.php'> ";
}

} else {

// Error voor Foutief wachtwoord
echo "<br><p align='center'>Wrong password or username!</p>";
}
}
}
?>

When the username is incorrect or the username has not been found a message should be displayed (last else function). This will not happen at the moment right now.. Anyone can tell me what I do wrong?
 
Old 06-01-2005, 02:46 AM   #2
enemorales
Member
 
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 30
It's very difficult to read your code, because it's not indented. You should put it between code tags. So far I have found only one thing in your code:

$_SESSION['user'] = $user;
$_SESSION['server'] = $servername;
if ( $_SESSION[user] == "admin" ) {

It seems as the single quotes are missing. Could this be the source of the error?
 
Old 06-01-2005, 04:19 AM   #3
Erhnam
Member
 
Registered: Jan 2005
Posts: 54

Original Poster
Rep: Reputation: 15
Nope this is not fixing the problem...
 
Old 06-01-2005, 06:47 AM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,614

Rep: Reputation: 136Reputation: 136
Try remove the last } from your code
 
Old 06-01-2005, 07:48 AM   #5
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
The brace balance looks okay. Is the problem that the "if ($cryptpw == $passwd[1]) is always evaluating true?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP !!! php mail function akamaru607 Programming 22 08-26-2005 02:44 PM
php HTTP_RAW_POST_DATA no value in function dinges Programming 1 12-27-2004 11:59 AM
php HTTP_RAW_POST_DATA na value in function dinges Linux - Software 1 12-26-2004 04:11 AM
Passing one php function result as a parameter to another php function davee Programming 13 09-12-2004 12:08 PM
Using the PHP mail() Function !?!? Hdata Programming 0 06-22-2003 06:02 AM


All times are GMT -5. The time now is 05:21 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration