You are here: Wierd PHP Problem « PHP « IT news, forums, messages
Wierd PHP Problem

Posted by Ahmed Abdel-Aliem on 02/23/05 23:22

Hi
i use the following code as a login page for a restricted area
it works fine on some servers when i enter the right username and password
but it doesn't work on some servers when i enter the right username
and password, and returns wrong username and password
can any one tell me what possible reasons could make this code works
on some servers and doesn't on other servers ?

here is the code :
<?
session_start();
include 'config.php';
$username = $HTTP_POST_VARS['username'];
$password = $HTTP_POST_VARS['password'];
if((!$username) || (!$password)){
include 'header.html';
echo "<font color=\"#990000\"><b>Please enter ALL of the
information!</b></font> <br />";
include 'login_form.html';
include 'footer.html';
exit();
}
$sql = mysql_query("SELECT * FROM users WHERE username='$username'
AND password='$password'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
session_register('user_id');
$_SESSION['user_id'] = $user_id;
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
session_register('username');
$_SESSION['username'] = $username;
header("Location: login_success.php");
}
}else{
include 'header.html';
echo "<font color=\"#990000\"><b>You could not be logged in! Either
the username and password do not match!</b></font><br />
<font color=\"#990000\"><b>Please try again!</b></font><br />";
include 'login_form.html';
include 'footer.html';
}
?>

--
Ahmed Abdel-Aliem
Web Developer
www.ApexScript.com
0101108551

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация