Current location: Hot Scripts Forums » Programming Languages » PHP » _SESSION['email'] not working


_SESSION['email'] not working

Reply
  #1 (permalink)  
Old 08-06-07, 04:42 AM
MrTeenie MrTeenie is offline
Newbie Coder
 
Join Date: Aug 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
_SESSION['email'] not working

Alright I want it to show the persons e-mail when they are loged in on this profile page so that they can change their account e-mail... this is the forum code

PHP Code:

<tr><td>    Email:</td><td> <input type="text" id="email" name="email" size="32" value="<?php echo $_SESSION[email];?>" /></td></tr>
and when the session is created it adds email into it.

PHP Code:

                    session_start();

                    
$_SESSION['user_id'] = $row['ID'];
                    
$_SESSION['user'] = $row['Username'];
                    
$_SESSION['email'] = $row['Email'];
                    
$_SESSION['logged_in'] = TRUE
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-06-07, 04:50 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Echo $row['Email']; and see if it contains the expected email address. Also, is there a session_start() on the page where you want to display it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-06-07, 05:08 AM
MrTeenie MrTeenie is offline
Newbie Coder
 
Join Date: Aug 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
neither of the solutions worked.

profile.php

PHP Code:

<?php
session_start
();
require_once(
'db.php');
include(
'functions.php');
include(
'ads.php');
?>
<center><table border="0" cellspacing="0">
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<tr><td>    Password:</td><td> <input type="password" id="password" name="password" size="32" value="" /></td></tr><br />
<tr><td>    Re-password:</td><td> <input type="password" id="password_confirmed" name="password_confirmed" size="32" value="" /></td></tr><br />
<tr><td>    Email:</td><td> <input type="text" id="email" name="email" size="32" value="<?php echo $row['Email']; ?>" /></td></tr><br />
<tr><td>    <input type="submit" name="register" value="register" /></td></tr><br />
</form></table></center>
login.php

PHP Code:

<?php
    
if(isset($_POST['Login']))
    {
        if(
$_POST['username']!='' && $_POST['password']!='')
        {
            
//Use the input username and password and check against 'users' table
            
$query mysql_query('SELECT ID, Username, Active FROM users WHERE Username = "'.mysql_real_escape_string($_POST['username']).'" AND Password = "'.mysql_real_escape_string(md5($_POST['password'])).'"');
            
            if(
mysql_num_rows($query) == 1)
            {
                
$row mysql_fetch_assoc($query);
                if(
$row['Active'] == 1)
                {
                    
session_start();
                    
$_SESSION['user_id'] = $row['ID'];
                    
$_SESSION['user'] = $row['Username'];
                    
$_SESSION['email'] = $row['Email'];
                    
$_SESSION['logged_in'] = TRUE;
                }
                else {
                    
$error 'Your membership was not activated. Please open the email that we sent and click on the activation link';
                }
            }
            else {        
                
$error 'Login failed !';        
            }
        }
        else {
            
$error 'Please user both your username and password to access your account';
        }
    }
?>

<?php if(isset($error)){ echo $error;}?>

<?php if( $_SESSION['logged_in'] == FALSE) {
     echo
"<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">
    Username: <input type=\"text\" id=\"username\" name=\"username\" size=\"15\" value=\"\" />
    Password: <input type=\"password\" id=\"password\" name=\"password\" size=\"15\" value=\"\" />
    <input type=\"submit\" name=\"Login\" value=\"Login\" />
</form>"
;}
    else{ echo 
"Edit your <a href=\"profile.php\">Profile</a> or <a href=\"logout.php\">Logout</a>.";
    } 
    
?>
the sessions_start() is in the header.php that is running off the index...

http://future.psnathome.com is the site.

Last edited by MrTeenie; 08-06-07 at 05:14 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 08-06-07, 07:01 AM
MrTeenie MrTeenie is offline
Newbie Coder
 
Join Date: Aug 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
I figured it out on my own, thanks for trying to help I just hadn't given you all the code before so you could not see that I had not called Email when query database.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form with Photo Upload not working HELP ! mckenzie ASP 1 11-02-06 03:46 PM
footer working in some browsers but not all pkcidstudio CSS 6 08-25-06 09:39 AM
ASP not working in IIS5 on WinXP Pro cistate ASP 5 06-18-04 03:31 PM
[SOLVED] isLeapYear not working? viper2843 Everything Java 2 05-17-04 07:11 PM
calendar working until months changed bitesize JavaScript 1 01-13-04 02:50 PM


All times are GMT -5. The time now is 06:45 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.