I have following code, a php that checks a username and password (nv_checklogin.php) It includes a config.php which links to a database (storing usernames and passwords).
If I echo the $count right before the header, it outputs "1" on the screen (so i'm sure the link with the database has been made correctly, and the code enters the if-loop). If I add " echo 'a'; " right after the header, it outputs " a ".
What could be wrong? It worked before, I am now updating my mysql-commands into mysqli since my files have been moved by the host, and my site didn't work anymore. There are no blank lines in the config.php file (not after the ?> ).
If I log in on the site, the nv_checklogin.php is called. It now gives me a blank screen instead of redirecting me to nv_frames.php. If I right-click on the screen and check the properties of the page, I can see I am still on the nv_checklogin.php page.
Thanks in advance for your help/information.
(entering a wrong username/password combination also leads to the correct output (verkeerde naam en/of paswoord).
config.php
<?php
// Connection's Parameters
$db_host="localhost";
$db_name="kleinpruts_copp1";
$username="kleinpruts_prono";
$password="xxxx";
$dbtimc = mysqli_connect($db_host, $username, $password, $db_name);
?>
nv_checklogin.php
<?php
session_start();
echo '<link rel="stylesheet" type="text/css" href="nv_style1.css">';
$_SESSION['login']=false;
$_SESSION['gebruiker']='test';
$_SESSION['naam']='test';
$_SESSION['voornaam']='test';
include('config.php');
// username and password sent from form
$mygebruikersnaam=$_REQUEST['mygebruikersnaam'];
$mypassword=$_REQUEST['mypassword'];
// To protect MySQL injection
$mygebruikersnaam = stripslashes($mygebruikersnaam);
$mypassword = stripslashes($mypassword);
$mygebruikersnaam = mysqli_real_escape_string($dbtimc,$mygebruikersnaam);
$mypassword = mysqli_real_escape_string($dbtimc,$mypassword);
$sql="SELECT * FROM deelnemers WHERE gebruikersnaam='$mygebruikersnaam' and paswoord=SHA1('$mypassword')";
$result=mysqli_query($dbtimc,$sql);
$count=0;
// Mysql_num_row is counting table row
$count=mysqli_num_rows($result);
// If result matched $mygebruikersnaam and $mypassword, table row must be 1 row
if($count==1){
$_SESSION['login'] = true;
$_SESSION['gebruiker'] = $mygebruikersnaam;
session_write_close();
header("Location:nv_frames.php");
exit();
} // end else
else {
echo '<p>Verkeerde naam en/of paswoord!</p>';
} // end else