hi all
i seem to be having a problem with session variables, and registering sessions. i am runing wamp5 and i think that i need to change something in the php.ini file cause i basicaly coppied the code from a login script that works on my server(php v4.somthing) so i think the problem is v5. following is the code from login.php.
[PHP]
<?
$host="localhos t"; // Host name.
$db_user="eric" ; // MySQL username.
$db_password="d al4120"; // MySQL password.
$database="wytr kcms"; // Database name.
$cms = mysql_pconnect( $host, $db_user, $db_password) or trigger_error(m ysql_error(),E_ USER_ERROR);
mysql_select_db ($database, $cms);
if(isset($_POST[uname]))
$user=$_POST[uname];
if(isset($_POST[pass]))
$pass=$_POST[pass];
//session_start() ;
//session_destroy ();
$result=mysql_q uery("SELECT user, pass FROM users WHERE pass = '$pass' AND user='$user'");
$row=mysql_fetc h_row($result);
if($row[0] == $user && $row[1] == $pass)
{
//session_registe r("user");
//header("locatio n:index.php");
thisisapain(1);
}
else
{
//header("locatio n:login.htm");
thisisapain(2);
}
function thisisapain($ah ah)
{
if ($ahah == 1)
{
session_start() ;
session_destroy ();
//session_registe r("user");
$_SESSION[user]='registered';
header("locatio n:index.php");
}else if($ahah == 2)
{
echo "frig";
//header("locatio n:login.htm");
}
}
?>
[/PHP]
if i log in correctly it displays the incorrect login message(frig) but if it is correct it redirects me to index.php. and index.php then processes this code at the very top of the file
[PHP]
<?
session_start() ;
if($_SESSION[user]!='registered')
{
header("locatio n:login.htm");
}
?>
[/PHP]
and this redirects me back to login.htm
any advice would be greatly appreciated
eric
i seem to be having a problem with session variables, and registering sessions. i am runing wamp5 and i think that i need to change something in the php.ini file cause i basicaly coppied the code from a login script that works on my server(php v4.somthing) so i think the problem is v5. following is the code from login.php.
[PHP]
<?
$host="localhos t"; // Host name.
$db_user="eric" ; // MySQL username.
$db_password="d al4120"; // MySQL password.
$database="wytr kcms"; // Database name.
$cms = mysql_pconnect( $host, $db_user, $db_password) or trigger_error(m ysql_error(),E_ USER_ERROR);
mysql_select_db ($database, $cms);
if(isset($_POST[uname]))
$user=$_POST[uname];
if(isset($_POST[pass]))
$pass=$_POST[pass];
//session_start() ;
//session_destroy ();
$result=mysql_q uery("SELECT user, pass FROM users WHERE pass = '$pass' AND user='$user'");
$row=mysql_fetc h_row($result);
if($row[0] == $user && $row[1] == $pass)
{
//session_registe r("user");
//header("locatio n:index.php");
thisisapain(1);
}
else
{
//header("locatio n:login.htm");
thisisapain(2);
}
function thisisapain($ah ah)
{
if ($ahah == 1)
{
session_start() ;
session_destroy ();
//session_registe r("user");
$_SESSION[user]='registered';
header("locatio n:index.php");
}else if($ahah == 2)
{
echo "frig";
//header("locatio n:login.htm");
}
}
?>
[/PHP]
if i log in correctly it displays the incorrect login message(frig) but if it is correct it redirects me to index.php. and index.php then processes this code at the very top of the file
[PHP]
<?
session_start() ;
if($_SESSION[user]!='registered')
{
header("locatio n:login.htm");
}
?>
[/PHP]
and this redirects me back to login.htm
any advice would be greatly appreciated
eric
Comment