Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

adding a php command


lucilue2003

Recommended Posts

Posted

HI,

 

I want to be able to have a user click on a link and have the php remember the posted data. It seems that when they hit back or refresh, that posted data is gone. Is there a way to remember it throughout the time the user is on the site ?

 

something like this:

 

<a href=http://www.mysite.com/index.php?bgcolor=red>i want this to be my background color</a>

 

$bgcolor = $_GET['bgcolor'];

 

thanks.

Posted
$bgcolor = $_GET['bgcolor'];
tep_session_register('bgcolor');

Posted
$bgcolor = $_GET['bgcolor'];
tep_session_register('bgcolor');

 

Here's what i got:

Fatal error: Call to undefined function: tep_session_register() in /home/elita/public_html/newsite/includes/configure.php on line 39

 

The function is there because when i place that code inside index.php it works fine.

 

I really need it be done inside configure.php. based on the background color they choose, i have different database that load.

 

is there a way so that i can get it to work?

 

I tried this one trick but no luck:

index.php:

...

require('includes/application_top.php');

$currid = $_GET['currid'];

tep_session_register('currid');

 

ALSO

includes/configure.php

if (!isset($currid)) $currid = $_GET['currid'];

if ($currid =="red")

define('DB_DATABASE', 'red');

else if ($currid =="blue")

define('DB_DATABASE', 'blue');

else if ($currid =="orange")

define('DB_DATABASE', 'orange');

 

when i load the index.php page

http://www.mysite.com/index.php?currid=orange

 

it says :

1046 - No Database Selected

select configuration_key as cfgKey, configuration_value as cfgValue from configuration

 

please help.

Posted

But, make sure it is below the code in application_top.php that starts the session.

Posted

here's my file layout:

 

index.php

require('includes/application_top.php');

$currid = $_GET['currid'];

tep_session_register('currid');

 

application_top.php -

// start the session

$session_started = false;

if (SESSION_FORCE_COOKIE_USE == 'True') {..}

elseif (SESSION_BLOCK_SPIDERS == 'True') {..}

else {..}

$_SESSION['currid'] = $_GET['currid'];

 

configure.php

if (!isset($currid)) $currid = $_GET['currid'];

if ($currid =="red")

define('DB_DATABASE', 'red');

else if ($currid =="blue")

define('DB_DATABASE', 'blue');

else if ($currid =="orange")

define('DB_DATABASE', 'orange');

 

is this how it is supposed to be ? thanks.

Posted

No...there is a lot of redundant code there.

 

Also, a defined constant can only be defined once. What you are needing is a database abstraction layer which osC MS2 does not have.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...