Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Pass a variable to a URL


RenFromPenn

Recommended Posts

thats php code as an example there has to be inside a <?php ?> block,

so ok in your case as you had the old code that worked for simple links when you call the redirect function

 

<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . rawurldecode(REDIRECT_LINK), NONSSL, false) . '"target="_blank">' . '<img src="includes/languages/english/images/buttons/button_continue.gif" border="0" alt="Continue" title=" Continue " width="85" height="20">' . '</a>';
echo $refer_string;

 

Then having the entire definition with the REDIRECT_LINK should work.

Link to comment
Share on other sites

  • Replies 67
  • Created
  • Last Reply

I've tried the link here and pretty much works. Anyways, to have the jscript coveing the mouseover just enter in the table element of the html code that encloses the link onMouseOver="return true;" and that should do it.

 

Example:

<td onMouseOver="return true;">link code here</td>

Link to comment
Share on other sites

I have just discovered that appending with an email address causes a problem. The tracking software doesn't support the @ sign. It only supports alphanumeric characters. Is there a way to replace the @ sign in the email address that is being appended with another character? Perhaps some sort of if then statement?

Link to comment
Share on other sites

once you have the final link done (including the email address) use the rawurlencode function like in this example. That should had worked with the original redirection too.

 

<?php
$refer_string = '<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . rawurlencode(REDIRECT_LINK), NONSSL, false) . '"target="_blank">' . '<img src="includes/languages/english/images/buttons/button_continue.gif" border="0" alt="Continue" title=" Continue " width="85" height="20">' . '</a>'
echo $refer_string; 
?>

 

If you still have the redirection code check if it was rawurldecode (incorrectly set in one of my code posts). Should been rawurlencode for this to work.

 

Also if the email address needs to be converted to a number you'll need to know the conversion scheme. So [email protected] how it ends up with a number like 123.

Link to comment
Share on other sites

I don't need the whole email address converted. The tracking system supports everything except the @ and the dot. I was thinking that it might be simpler to track using a username, but that would mean that I would have to install the username contrib and some of the installation instructions don't make sense to me. That would also mean that the code you wrote to define the email_address variable would have to be rewritten to define the username variable. Could you have a look at my post about the username variable and see if you can make sense of how to install it? Also, how would the following code need to be changed to define the username variable?

 

<?php $customer_query = tep_db_query("select customers_id, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
if($customer = tep_db_fetch_array($customer_query) ) {
$email_address = $customer['customers_email_address'];
}

?>

 

Also, about this bit of code:

 

<?php
$refer_string = '<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . rawurlencode(REDIRECT_LINK), NONSSL, false) . '"target="_blank">' . '<img src="includes/languages/english/images/buttons/button_continue.gif" border="0" alt="Continue" title=" Continue " width="85" height="20">' . '</a>'
echo $refer_string;
?>

 

What happened to the $email_address variable? It )or if we are switching to a username variable) still needs to be included in the code.

Link to comment
Share on other sites

why dont you pass the customer id instead? Has to be an email or username? Also what the username contribution link?

 

I didn't know there was such a thing as a customer ID. The reason I was using the email or a username is because the variable has to be something that I can see when I access the customer area in the admin panel. I need to be able to match the passed variable to a particular customer. I don't see the customer ID anywhere in the Customers area of the admin panel. How would I even determine which ID is assigned to which customer?

 

The username contribution is located here.

Link to comment
Share on other sites

Ok, now reading your other post and looking the username contribution I understand you haven't updated the dbase. To update the dbase you need to use a tool like phpmyadmin. Your host may aldready has this online so you could ask them. (Usually they do)

 

The alternative will be to utilize the customers_id field. A far easier approach does not require mods to the dbase.

 

To do that you can do the following: (backup your catalog\admin\customers.php

 

1. Open your catalog\admin\customers.php file locate this line of code:

				<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LASTNAME; ?></td>

 

Just above it add this code

				 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_CUSTOMER_ID; ?></td>

 

2. Same file Locate this line of code

				<td class="dataTableContent"><?php echo $customers['customers_lastname']; ?></td>

 

Just above it add this code:

				<td class="dataTableContent" align="center"><?php echo $customers['customers_lastname']; ?></td>

 

3. Open your catalog\admin\includes\languages\english\customers.php file

Add this line of code:

define('TABLE_HEADING_ORDER_ID', 'ID');

 

Then, if everything is ok when you list your customers you should see their id field in the admin panel.

Link to comment
Share on other sites

I have the customer IDs displaying in the admin area now. Just out of curiousity, why doesn't the system reassign customer numbers if you deleted an account? I have created a few accounts to test the system, but right now I only have two with customer numbers 2 and 14. If numbers were being reassigned they would be 1 and 2.

 

Anyway, how do I change this code from defining the email variable to defining the customer id variable?

 

<?php $customer_query = tep_db_query("select customers_id, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
if($customer = tep_db_fetch_array($customer_query) ) {
$email_address = $customer['customers_email_address'];
}

?>

 

Also, in the other code that you provided the variable seems to be missing. Where would I add it?

 

<?php
$refer_string = '<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . rawurlencode(REDIRECT_LINK), NONSSL, false) . '"target="_blank">' . '<img src="includes/languages/english/images/buttons/button_continue.gif" border="0" alt="Continue" title=" Continue " width="85" height="20">' . '</a>'
echo $refer_string;
?>

Link to comment
Share on other sites

Ok so earlier we had this code to get the email:

 

<? php
  $customer_query = tep_db_query("select customers_id, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
 if($customer = tep_db_fetch_array($customer_query) ) {
 $email_address = $customer['customers_email_address'];
 }
?>

 

so now we change that for a quick test to:

<? php
  $customer_query = tep_db_query("select customers_id, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
 if($customer = tep_db_fetch_array($customer_query) ) {
 $email_address = $customer['customers_id'];
 }
?>

 

the id is based on an auto-increment mechanism in the dbase. If you delete customers in between the id number will keep incrementing. You will have to defrag the sql table to have the numbers reassigned back to 1,2,3 etc

 

So try this see if it will pass through this time.

Link to comment
Share on other sites

take out this extra space I had it wrong:

<? php

 

make it

<?php

 

and post the code you have (just change the link so it doesnt have the refer details you know).

Link to comment
Share on other sites

Here you go:

 

<?php
/*
$Id: books.php,v 1.22 2003/06/05 23:26:23 hpdl Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/
require('includes/application_top.php');
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_BOOKS);

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_BOOKS, '', 'SSL'));

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

$customer_query = tep_db_query("select customers_id, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
if($customer = tep_db_fetch_array($customer_query) ) {
$email_address = $customer['customers_id'];
}
?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="2" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
 </table></td>
<!-- body_text //-->
 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
  <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
  <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
</tr>
<tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListing">
 <tr>
<td align="left" class="productListing-heading"> Merchant </td>

<td class="productListing-heading"> Offer Details </td>
<td align="left" class="productListing-heading"> Price </td>
<td align="left" class="productListing-heading"> Visit Site </td>
 </tr>
 <tr class="productListing-odd">
<td valign="top" align="left" class="productListing-data"> Product Name Here </td>
<td valign="top" class="productListing-data">Description here </td>

<td valign="top" align="left" class="productListing-data"> Price Here </td>
<td valign="top" align="left" class="productListing-data"><?php
  $refer_string = '<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . YAHOO_LINK . $email_address, NONSSL, false) . '"target="_blank">' . '<img src="includes/languages/english/images/buttons/button_continue.gif" border="0" alt="Continue" title=" Continue " width="85" height="20">' . '</a>';
  echo $refer_string;
?> </td>
 </tr>
</table>
</td>
</tr></table>
</td></table>
<!-- body_text_eof //-->
 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
 </table></td>
</tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

ok so I cannot see why the customer id is not appended. Double check it because it would be just 1 digit to the reference number. Now to verify that the id is set I modified this part:

 

$customer_query = tep_db_query("select customers_id, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
if($customer = tep_db_fetch_array($customer_query) ) {
$email_address = $customer['customers_id'];
}

 

to this:

$customer_query = tep_db_query("select customers_id, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
 if($customer = tep_db_fetch_array($customer_query) ) {
$email_address = $customer['customers_id'];
 } else {
$email_address = 'Failure';
 }

So try to replace this part if the id really fails you should see a "Failure" appended to the end of the string. This should work (at least its going to show if the id is set or not) because the only thing we changed was the $customer['customers_id'];

Link to comment
Share on other sites

change this:

 

(int)$customers_id

 

to this:

 

(int)$customer_id

 

should be ok then

 

And I am posting the whole thing just to be sure (correct this time I hope):

 

<?php
$customer_query = tep_db_query("select customers_id, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
if($customer = tep_db_fetch_array($customer_query) ) {
$email_address = $customer['customers_id'];
}
?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...