Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Creating a login page to shop


vinnie@krystal

Recommended Posts

Posted

Hi could anyone help pls...i have created my shop what i am trying to create is a login page before customers are able to view products. Its more of a php related query.

 

So here it is once the user enters username and password the scripts would verify this is correct by an (if) statement this would then take the user to shopping cart sitting at index.php on my domain. The script with the login page details is secretdb.php but for some reason browsing the page is refreshed with the url stating www.mydomain.net/secretb.php.. I need the script to take me to www.mydomain.net/index.php. How would this be achieved. The code is shown below

 

if ($count > 0)

 

{

//visitor's name and password combination are correct

require('index.php');

 

 

}

else

{

//visitor's name and password combination are not correct

echo '

 

 

Your guidance will be very much appreciated...thanks

Posted

I didnt get what you meant by that 'require('index.php');'

if index.php is a page and you need to show it, then what you need is header tag, not require tag,

correct me if i am wrong, but if you want to redirect to index page you need to call

header("Location:index.php");

AruN

Posted

Ok i have two seperate pages created one secretdb.php and index.php. Now the secretdb.php is my login page where i have set a username and password where the user would need to be registered prior to viewing index.php.

 

What i am trying to get at here is the secretdb.php page once authentication process is ok the user is redirect to index.php. However if the user details are not correct the user needs to stay in secretdb.php and try again.

 

what i am getting is once the user is ok they still remain within the secretdb.php page and the page has errors. as its not redirecting it to index.php

 

i have tried using require and header functions but still have errors. To summarise i want code to take me to a url of http://www.mydomain.net/index.php instead i am stuck at http://www.mydomain/net/secretdb.php

 

I hope that clarifies thanks.

Posted

require tag wont help in redirecting.I am pretty sure of that, try deleting spaces above header tag, header tag wont work if there is any space(or echo or print statements) above the header tag tag

AruN

Posted

Try adding this at the top of your index.php file right after

 

  require('includes/application_top.php');

 

 

  if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_SECRETDB, '', 'SSL'));
 }

 

you will of course have to define the FILENAME_SECRETDB in includes/filenames.php. You will also want to add it on any other page that you don't want people to see if they are not logged in such as product_info.php

 

You should also realize that Search Engines will then NOT be able to index any pages that you apply this to and this will dramatically effect the number of visitors to your site from search engines such as Google.

Posted

i have tried the header function and have the following errors;

 

Warning: Cannot modify header information - headers already sent by (output started at /home/psvltdne/public_html/secretdb.php:10) in /home/psvltdne/public_html/secretdb.php on line 117

 

any ideas...

Archived

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

×
×
  • Create New...