Error in my SESSION code
Posted: Thu Jun 25, 2009 12:16 pm
Hello,
I am new to php. I am designing a simple login form, which up on login retrieves few words from the database and displays to the user using SESSION. Unfortunately, my code isn't displaying any thing. All it displays is '0'.
Database structure:
Once all criteria for login is successfully executed I am using following code to implement session
and this is how i am displaying in display.php
Any help will be appreciated.
I am new to php. I am designing a simple login form, which up on login retrieves few words from the database and displays to the user using SESSION. Unfortunately, my code isn't displaying any thing. All it displays is '0'.
Database structure:
Code: Select all
single_word(
wordID integer not null auto_increment,
word char(60)
primary key (wordID));
game (
emailID Char(60)
userword Char(32),
usertext text,
PRIMARY KEY (postID),
FOREIGN KEY (userword) REFERENCES single_word(word));
userdata (
name varchar(30) DEFAULT NULL,
email varchar(60) NOT NULL,
activationpassword float DEFAULT NULL,
password text,
validation char(20)
banned char(20)
PRIMARY KEY (email)
)
Code: Select all
session_start();
$_SESSION['email']=$email;
if(isset($_SESSION['email'])){
// Oneword
$oneword = "SELECT sw.word FROM single_word sw WHERE sw.word NOT IN (SELECT g.userword FROM game g WHERE g.emailID='$email') limit 1";
$result = mysql_query($oneword) or die ("Ahh!Could not get from database");
$description = "SELECT description FROM single_word WHERE word ='$result'";
$description = mysql_query($description) or die ("Ahh! could not get DESCRIPTION from database");
$_SESSION['oneword'] = $oneword;
$_SESSION['description'] = $description;
mysql_close($con);Code: Select all
<?php
if(isset($_SESSION['email'])){
$description = $_SESSION['description'];
$oneword = $_SESSION['oneword'];
}
?>
<?php print $description ?>
<?php print $oneword ?>