?
Solved

PHP syntax OScommerce

Posted on 2006-05-17
3
Medium Priority
?
895 Views
Last Modified: 2012-06-21
I have a page that uses oscommerce

The last page of the order system i redirects using this:

    if (strlen($notify_string) > 0) $notify_string = substr($notify_string, 0, -1);

    tep_redirect(tep_href_link(FILENAME_DEFAULT, $notify_string));
  }

I believe the tep_redirect(tep_href_link(FILENAME_DEFAULT, $notify_string));

is what is directing the page to the new page.  Because my server has the secure directory in another folder it is trying to find the index.php page in the wrong folder.  How can I change the above code to go straigt to the home page at http://www.jansboatproducts.biz?
0
Comment
Question by:muligruber
  • 2
3 Comments
 
LVL 2

Expert Comment

by:topscoder
ID: 16702339
i don't know the api of the functions of oscommerce, but you could redirect using the header() function of PHP like:

<?php
if (strlen($notify_string) > 0) $notify_string = substr($notify_string, 0, -1);
     // do not use the next function, so comment that line
     // tep_redirect( tep_href_link( FILENAME_DEFAULT, $notify_string));
     // but use the header function of PHP
     header("Location: http://www.jansboatproducts.biz");
}
0
 
LVL 2

Accepted Solution

by:
topscoder earned 2000 total points
ID: 16702430
well, i just checked the tep_redirect function.

<?php
  20  ////
  21  // Redirect to another page or site
  22    function tep_redirect($url) {
  23      if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page
  24        if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
  25          $url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
  26        }
  27      }
  28  
  29      header('Location: ' . $url);
  30  
  31      tep_exit();
  32    }
?>
as you can see, the tep_redirect function also uses the header function of PHP.

if you still want to use the osCommerce function, you could use the next code i think:

<?php
if (strlen($notify_string) > 0) $notify_string = substr($notify_string, 0, -1);
     tep_redirect( "http://www.jansboatproducts.biz" );
}
0
 
LVL 5

Expert Comment

by:aminerd
ID: 16702739
I'd examine the value of FILENAME_DEFAULT; that may be the better place to modify the redirection. For instance, right about the tep_redirect, add:

var_dump(FILENAME_DEFAULT); die();

Now, do whatever you'd normally do to fire the redirect. You'll get the value of that constant instead. Changing the constant definition means you only have to change this in one place.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 2 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question