Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 06-01-2005, 03:26 AM   #1
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, 03:46 AM   #2
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 31
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, 05:19 AM   #3
Registered: Jan 2005
Posts: 54

Original Poster
Rep: Reputation: 15
Nope this is not fixing the problem...
Old 06-01-2005, 07:47 AM   #4
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 5,473

Rep: Reputation: 420Reputation: 420Reputation: 420Reputation: 420Reputation: 420
Try remove the last } from your code
Old 06-01-2005, 08:48 AM   #5
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?


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 03:44 PM
php HTTP_RAW_POST_DATA no value in function dinges Programming 1 12-27-2004 12:59 PM
php HTTP_RAW_POST_DATA na value in function dinges Linux - Software 1 12-26-2004 05:11 AM
Passing one php function result as a parameter to another php function davee Programming 13 09-12-2004 01:08 PM
Using the PHP mail() Function !?!? Hdata Programming 0 06-22-2003 07:02 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:10 AM.

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