I am having trouble trying to pass my username variable from a login page to the next 'welcome' page. I am hosting the web pages using my university's server and therefore access my web files within a public_html folder.
When testing on the login.php page I am able to print the username that is held in the session however when I try the same in the member's page it does not print the username held in the session array? I have checked all other posts however no solution seems to work.
Login.php
<?php
session_start();
include ('connect.php');
$userName=$_POST['username'];
$password=$_POST['password'];
$result = mysql_query("SELECT * FROM users WHERE username='$userName' AND password='$password'") or die ('Query is invalid: ' . mysql_error());;
$count = mysql_num_rows($result);
if($count==1)
{
$_SESSION['username']=$userName;
header("Location: memberPage.php");
} else {
echo "Incorrect username or password";
}
?>
memberLogin.php
<?php
session_start();
include ('connection.php');
$_SESSION['username'] = $userName;
echo $userName;
//$result = mysql_query("SELECT * FROM users");
//while ($row = mysql_fetch_array($result)) {
// echo $row['username'];
//}
?>
<html>
<link rel="stylesheet" type="text/css" href="style.css" />
<div id = main-nav>
<a href="http://www.cs.nott.ac.uk/~rxp00u/logout.php" >Logout</a>
</div>
</html>
P.S. I realise my code is not very secure and I will be working on this after getting the basic framework of the website working!
EDIT: Error reporting on login.php shows the following error: "Warning: Unknown: open(/var/lib/php5/sess_d760m9ebgose4liptp6jbgbc17nqjgg4, O_RDWR) failed: Permission denied (13) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php5) in Unknown on line 0"