I am using PHP 5.3 iis7 and SLQ Server 2005. I know the script gets to the session part and creates a temp file in C:/windows/temp folder (see info below), but when I try to login and redirect to the index.php it give a 500 error on the login.php page.
login.php
index.php
conifg.php
temp file - C:\windows\temp
<?php
//set ini
ini_set('session.gc_maxlifetime', 900);
if(!ini_get('session.auto_start')){
session_start();
}
// include file
include ('config.php');
include (LIB_PATH.'functions.php');
include(LIB_PATH.'sqlsrv_connect.php');
if($_SESSION['user_id']){
Header("Location: index.php");
}
if($_POST['submit']){
$user1 = trim($_POST['user']);
$pass1 = trim($_POST['pass']);
$user= "'$user1'";
$pass= "'$pass1'";
if($user == '' or $pass == ''){
$error = 'You forgot to enter your user_name and your password!';
}else{
$query = "SELECT * FROM users WHERE user_name = $user and pass = $pass";
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$r = sqlsrv_query ($database, $query, $params, $options);
$num = sqlsrv_num_rows($r);
if ($num >0) {
while ($user_data = sqlsrv_fetch_array($r, SQLSRV_FETCH_ASSOC)) {
$_SESSION['user_id'] = $user_data['user_id'];
$_SESSION['user_name'] = $user_data['user_name'];
$_SESSION['user_level'] = $user_data['user_level'];
$_SESSION['user_rep'] = $user_data['rep'];}
Header("Location: index.php");
}else{
$error = 'Wrong username or password!';
}
}
}
//template
include(TEMP_PATH.'login_tpl.php');
?>
<?php
//set ini
ini_set('session.gc_maxlifetime', 900);
if(!ini_get('session.auto_start')){
session_start();
}
// include file
include ('config.php');
//include (LIB_PATH.'functions.php');
include(LIB_PATH.'sqlsrv_connect.php');
if(!$_SESSION['user_id']){
Header("Location: login.php");
}
$database
//template
include(TEMP_PATH.'index_tpl.php');
?>
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Login php with session not redirecting to index.php
in Microsoft IIS
Posted
I am using PHP 5.3 iis7 and SLQ Server 2005. I know the script gets to the session part and creates a temp file in C:/windows/temp folder (see info below), but when I try to login and redirect to the index.php it give a 500 error on the login.php page.
login.php
index.php
conifg.php
temp file - C:\windows\temp