thanks for the quick answer brad!
yes I am displaying all the php errors.
First I tried to remove the 2 lines at the top and that wasn't it.
I removed session_regenerate_id when the login is succesfull and then it worked 😮
might been the 2 lines at the top aswell.
The thing is now that when a user enters an invalid account name or password I get stuck at
my loginexe.
It works fine if the user leaves one or both boxes empty or if the user enter the right information.
<?php
session_start();
if(isset($_POST['submit'])){
if(isset($_SESSION['account_name'])){
header('location: index.php');
exit();
}
ob_start();
//includes database connection details.
require_once('config.php');
// checks error.
$error = false;
// connects to the server.
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link){
die('failed to connect to server');
}
$db = mysql_select_db(DB_NAME,$link);
if(!$db){
die('Unable to connect to database');
}
//Sanitize the POST values
$login = mysql_real_escape_string($_POST['login']);
$password = mysql_real_escape_string($_POST['password']);
if($login==''){
$error_array = 'login ID missing. ';
$error = true;
}
if($password==''){
$error_array += 'password ID missin. ';
$error = true;
}
if($error){
session_destroy();
session_start();
$_SESSION['ERRMSG_ARR'] = "U have to fill in both fields :O";
session_write_close();
header('location: login.php');
ob_end_flush();
exit();
}
$sql=mysql_query("
SELECT * FROM new_table3
WHERE id_acc='$login'
AND id_pass='".md5($password)."'
") OR die("failed to recieve info");
$check = mysql_num_rows($sql) OR die(mysql_error());
if($check>0){
$_SESSION['account_name'] = $login;
session_write_close();
header('location: index.php');
ob_end_flush();
exit();
}
mysql_close();
unset($_POST['submit']);
session_destroy();
session_start();
$_SESSION['ERRMSG_ARR'] = "Wrong account name or Password.";
session_write_close();
header('location: login.php');
ob_end_flush();
exit();
}
?>