Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP If statement


gaaro

Recommended Posts

People,

 

I need some help here

On my default.php page i want to use a code like his:

 

 

<?php if (!tep_session_is_registered('customer_id')) {do nothing};)

else {include some page}; ?>

 

In normal language:If a visiter has logd-on there should happen nothing, but if a visitor has NOT logd-on there should be a unclude loaded with a log-on screen.

Question's

1. Why does this code give a parse error?

2. Is this the right way to try to accomplish this?

 

Harro

"If we don't succeed, we run the risk of failure." George W. Bush, Jr

Link to comment
Share on other sites

Would be much easier if you just did

if (!tep_session_is_registered('customer_id') tep_redirect(FILENAME_LOGIN);

 

stick this in your application_top.php then all pages are protected and if you don't want to go to the standard osc login page just change to whatever page you want.

Trust me, I'm an Accountant.

Link to comment
Share on other sites

If I understand your piece of code right, If i place this in de top, all pages are..secured.

 

I want to grant access to all my other pages, coz i have hidden the prices for quests, so it is ok if people browse around

It just would be a nice feature if there was a little login-field just above the new-products-for-october box

 

I haven't been able to try this code yet, but doesn's this redirect ALL guesst to the login-screen, and therefore not allowing them to see my main-page ?? In stead i would like a little login field if it is a guest, and nothing to happen if it is registerd?

 

Am i understanding the code wrong? OR does this code work just fine

(the reason i havent tried is because of server maintenaince, will be able to try in a few days)

"If we don't succeed, we run the risk of failure." George W. Bush, Jr

Link to comment
Share on other sites

Ok,

 

Your right, I mis-understood what your intention was.

 

In that case then surely on your default page you just need

if (!tep_session_is_registered('customer_id') include('login_box.php'):

Trust me, I'm an Accountant.

Link to comment
Share on other sites

tHANX,

 

i tried it, here's the code:

 <?php

   include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING);

   if (!tep_session_is_registered('customer_id') include('login_box.php'):

	 ?>

 

And then I receive this error:

Parse error: parse error, unexpected T_INCLUDE in C:htdocscatalogdefault.php on line 307

 

What is wrong here??

"If we don't succeed, we run the risk of failure." George W. Bush, Jr

Link to comment
Share on other sites

Also your missing a closing bracket (my fault)

 

<?php 

         include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); 

         if (!tep_session_is_registered('customer_id')) include('login_box.php');

        ?>

Trust me, I'm an Accountant.

Link to comment
Share on other sites

Nope...it was a whole different error!

 

It works now! It does exactly what i wanted it to do!

Guys you've been a great help! Thanx!

 

 

Harro

"If we don't succeed, we run the risk of failure." George W. Bush, Jr

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...