Jump to content

How to write PHP CODE?


aj123cd

Recommended Posts

I have a web site where users can gain points, when they use my site. For example, if the user spends $10.00 then the user will get 10 points.

In my web site there is a list of 10 retails (name). When the user clicks the link it will redirect to retailers website, where user can buy items.

How can I find out how much the user has spent on the retailer?

Thank you.

 

Link to comment
Share on other sites

Well, the way I see it, the retailer will need to know that your website was the source of the visitor (with the use of a url string or something similar, for this purpose we will call it a token).

Your links may look like this

<a href="http://www.retailer1.com?rtok=23523t23423">Retailer 1</a>

23523t23423 being the unique token for your user/website.

 

That token would need to be kept by the retailer from the start of the visit to the end of the transaction.

Once the transaction is made, it could send information back to your server with the token (that your website also understands) and stores the sales information.

 

This is a very rough idea as to how it could be done. Other people may have a different/more elegant solution.

Link to comment
Share on other sites

when a use signs-up at your site, give them a unique id. create a database where your retailer would have access to insert info. when you redirect them, the retailer is given the unique id with the purchase. on payment, the page would update the database on the users unique id and the amount spend/points.

ZulfadlyAshBurn thank you.

this means user retailer nned to enter the sales details, ?

Link to comment
Share on other sites

Or the retailer could give you an RSS feed of their items.

 

You then recreate their store on your own site, and act as a middleman. User pays you, you pay retailer, retailer ships items to customer.

thank u xyph.

What is RSS Feed?

Taking payment is bad for me. I will spend the money. :D

is there any other way?

Link to comment
Share on other sites

(keep in mind im making this all up as I go)

Once the purchase has been made, the retailers site could run a piece of code that has access into your system.

Their code reads the cookie, sees that it is a token from your site, extracts their user information and then runs code on your system.

 

A very crude example:

// This is on the retailers confirm page 
if ($purchase_successful) {
   $result = include('http://yoursite.com.au/purchase_confirmed.php?site='.$_SERVER['REQUEST_URI'].'&user='.$cookie_user.'&spend='.$order_total);
   if ($result) {
      // Credits added to account //
   } else {
      // Something went wrong //
   }
}

 

purchase_confirmed.php

$spend = mysql_real_escape_string($_GET['spend']);
$user = mysql_real_escape_string($_GET['user']);
$site = mysql_real_escape_string($_GET['site']);
$sql = "INSERT INTO `credits` (user,site,credits) VALUES ('".$user."','".$site."','".$spend."')";
return mysql_query($sql);

 

Or something :)

 

Edit: I dont even know if it is possible to use the return method on a URL included file.. but it seems logical whilst I was typing it.

Link to comment
Share on other sites

The same method by instead of using cookie, store it in the db. The retailer can also access this db.

true. thank you.

 

Buddski, ZulfadlyAshBurn, xyph

Thank you very much for all you help.

Apart from this method can you or anyone else think of any other method I can use?

Thank you.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.