Bit of a newbie here and hoped someone could help me?
All i'm trying to do is store more then one word in a $_SESSION. I've done a MySQL query to retrieve a member name from a database and this returns "Mr Brown". I've then stored the $memberName in a session like this:
$_SESSION['MemberName'] = $memberName;
If I echo straight after, it does give me "Mr Brown". But if I redirect to another page (header( 'Location: ../memberIndex.php' );) it doesn't get stored! It works ok if the $memberName is one word like "Bob", but as soon as there is a space in it, it doesn't transfer over. Other variables are stored ok as there ID numbers etc, its just this one? Can anyone help please? I've googled for ages and I can't see anything that lets me put two or more words into a $_SESSION variable?!? ...HELP!
<?
session_start();
$HTTP_POST_VARS["submit"];
$Username = $_POST['username'];
$Password = $_POST['password'];
$query = "SELECT * FROM MemberLogin WHERE username = '$Username' AND password = '$Password'";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
extract($row);
$_SESSION['MemberID'] = $id;
$_SESSION['MemberName'] = $memberName;
//echo $_SESSION['MemberName'];
header( 'Location: ../memberIndex.php' ) ;
}
Ok, bit of an update. I've just tried another script:
<?
session_start();
$_SESSION['MemberName'] = "Matt Brown";
//echo $_SESSION['MemberName'];
header( 'Location: testSession2.php' ) ;
?>
And when its transferred to testSession2.php, it works! So whats the difference? Where have I gone wrong? If I allocate the _SESSION with "Matt Brown", its ok. But if I allocated the _SESSION with $memberName that has "Matt Brown" in it, it doesn't?!? Oh i'm so confused!