[advanced search]
Results from the most recent live auction are here.
21 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Domain Name Industry Newsletter
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 05-27-2006, 01:28 PM   · #1
noswad
NamePros Regular
 
Location: Leeds, UK
Trader Rating: (1)
Join Date: Aug 2005
Posts: 260
NP$: 70.00 (Donate)
noswad is an unknown quantity at this point
PHP Session Help

Helloooo

Im using this PHP session to display data when a user logs in.

e.g.

session_start();
echo $_SESSION[console];

Basically - Its displaying their favourite games console in text.

The session will either display 'Xbox 360', 'Playstation 3' or 'Nintendo Wii'.

Is it possible to display a picture of their favourite console?

For example: if [console] = 'Xbox 360' -> display ../images/xbox360.jpg

You get what I mean!

Thanks for reading


Please register or log-in into NamePros to hide ads
__________________
C905 - Sony Ericsson mobile phone with an 8 megapixel camera!
noswad is offline   Reply With Quote
Old 05-27-2006, 01:52 PM   · #2
xlusive
Pro Coder & Designer
 
xlusive's Avatar
 
Name: Karim
Location: Netherlands
Trader Rating: (37)
Join Date: Apr 2005
Posts: 962
NP$: 62.00 (Donate)
xlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nice
Why not use cookies?

Because if you use sessions and they close theire window, they have to reassign what favorite console they have.

edit:
Code:
<?php if(isset($_POST['choose_console'])) { if($selection == "1") { $_SESSION['console_1'] = $console_1; session_register("console_1"); } } if(isset($_SESSION['console_1'])) { echo "<img src=picture.jpg>"; } ?> etc... (didnt test the code )
__________________
Capix
Dragonball RPG
Mamuzin

Last edited by xlusive : 05-27-2006 at 01:59 PM.
xlusive is offline   Reply With Quote
Old 05-27-2006, 01:54 PM   · #3
abdulmueid
NamePros Regular
 
abdulmueid's Avatar
 
Name: Abdul Mueid
Location: Mozambique
Trader Rating: (5)
Join Date: Jun 2005
Posts: 608
NP$: 1.85 (Donate)
abdulmueid has a spectacular aura aboutabdulmueid has a spectacular aura about
$favorite = $_SESSION[console];
$wii = "/home/user/public_html/wii.gif";
echo $favorite;
if ($favorite == "Wii") {
echo $wii;
}
abdulmueid is offline   Reply With Quote
Old 05-27-2006, 02:26 PM   · #4
Dan
Buy my domains.
 
Dan's Avatar
 
Name: Dan
Trader Rating: (63)
Join Date: Feb 2006
Posts: 2,801
NP$: 54.00 (Donate)
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
Autism Autism Autism Autism Autism Autism Autism
PHP Code:
session_start();

if (
$_SESSION['console'] == 'Nintendo Wii') {
  echo
'wii stuff <img src="wiiimage.jpg" />';
} elseif (
$_SESSION['console'] == 'Xbox 360') {
  echo
'360 stuff <img src="360.jpg" />';
} elseif (
$_SESSION['console'] == 'Playstation 3') {
  echo
'ps3 stuff <img src="ps3.jpg" />';
}


xlusive: your code has random variables that aren't used anywhere.
abdulmueid: yours wouldn't echo an image, just the path to it.
Dan is offline   Reply With Quote
Old 05-27-2006, 02:30 PM   · #5
noswad
NamePros Regular
 
Location: Leeds, UK
Trader Rating: (1)
Join Date: Aug 2005
Posts: 260
NP$: 70.00 (Donate)
noswad is an unknown quantity at this point
xlusive - the user chose their favourite console when they registered. Thanks any way.

Hi abdulmueid

I can't get this code to work but thanks for trying.

David.
__________________
C905 - Sony Ericsson mobile phone with an 8 megapixel camera!
noswad is offline   Reply With Quote
Old 05-27-2006, 02:37 PM   · #6
SecondVersion
while ($awake){ code(); }
 
SecondVersion's Avatar
 
Name: Eric
Location: Kentucky
Trader Rating: (142)
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (Donate)
SecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond repute
Member of the Month
MOTM September 2005 Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet
There are other..probably even better ways to do it, but:
PHP Code:
<?php

session_start
();

//I'm assuming you pull this info from the db
//on a login page, you could do the following

//if login successful
$_SESSION['console'] = $user_console_pref;

//Then wherever you want the image displayed

if (isset($_SESSION['console']))
{
    switch (
$_SESSION['console'])
    {
        case
'Nintendo Wii':
             
$console_stuff = 'wii stuff <img src="wiiimage.jpg" />';
             break;
        case
'Xbox 360':
             
$console_stuff = '360 stuff <img src="360.jpg" />';
             break;
        case
'Playstation 3':
             
$console_stuff = 'ps3 stuff <img src="ps3.jpg" />';
             break;
    }
    
    echo
$console_stuff;
}

?>
__________________

SecondVersion.com - The Personal Blog of SecondVersion
Domain Name Portfolio - Get your free copy. - Version 1.0.3 now available!!
SecondVersion is offline   Reply With Quote
Old 05-27-2006, 03:17 PM   · #7
noswad
NamePros Regular
 
Location: Leeds, UK
Trader Rating: (1)
Join Date: Aug 2005
Posts: 260
NP$: 70.00 (Donate)
noswad is an unknown quantity at this point
Thanks to both Dan Friedman and SecondVersion!

I was just about to kill myself!

Thanks again
__________________
C905 - Sony Ericsson mobile phone with an 8 megapixel camera!
noswad is offline   Reply With Quote
Old 05-27-2006, 03:54 PM   · #8
abdulmueid
NamePros Regular
 
abdulmueid's Avatar
 
Name: Abdul Mueid
Location: Mozambique
Trader Rating: (5)
Join Date: Jun 2005
Posts: 608
NP$: 1.85 (Donate)
abdulmueid has a spectacular aura aboutabdulmueid has a spectacular aura about
whoops... my bad. That was just a quick and dirty piece of code. Anyway, both your codes should work nicely
abdulmueid is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
RealTechNetwork EscrowDNS Hunting Moon
Advertise your business at NamePros
All times are GMT -7. The time now is 09:22 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0