Jump to content

encypting checkout form


isaac_cm

Recommended Posts

Hello,

I know there is alot of topics about encryption but I cant find out one suit what I want

 

I have a checkout form where buyer enter his/her info detail this form include hidden fields for the cart price, total, shipment , etc...

My big question here: how to encrypt the form data so when a slick user try to make a save as for the checkout page see only the encrypted data and cant modify any of the prices ?

 

 

if possible please tell me how to do it with MD5 I dont want to use third party like mcrypt coz I am sure my host vendor wont allowed

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/47407-encypting-checkout-form/
Share on other sites

There sure is...

 

 

First of all you should use sessions to store information about the customer (e.g. $_SESSION['name'] = "Customers name", $_SESSION['cart'] = "the items") and always represent an item in the shop by it's unique ID. So the customer buy items like: 345, 678, 12 ect. and when it comes to calculating the price you can look up item no. 345 in the database and get the price...

 

Look at this tutorial:

 

http://www.thewatchmakerproject.com/journal/276/building-a-simple-php-shopping-cart

I did all that, the problem is I use paypal as a gateway and I have to pass the total of the cart to paypal as a hidden field , from my knowledge someone could change that total then resend it to paypal this way he can buy product cost 500$ for only 0.01$

 

paypal force me to pass the info this way!!

hi again, I found a solution for this and I can keep using hidden fields please any body give me your opinion, I have to use hidden fields also because I use other third party tools for my shopping cart

 

//=========================== for code

<?php

$id=1;

$key=123;

$randKey="a$2**&kj1";

 

$token=sha1($id.$key.$randKey);

 

//do form stuff

echo "<input type='hidden' name='id' id='id' value='".$id."'>\n";

echo "<input type='hidden' name='key' id='key' value='".$key."'>\n";

echo "<input type='hidden' name='token' id='token' value='".$token."'>\n";

// end form stuff and page

?>

 

//======================= validate form

<?php

$randKey="a$2**&kj1";

$id=intval($_POST['id']);

$key=intval($_POST['key']);

$token=$_POST['token'];

 

$formValueHash=sha1($id.$key.$randKey);

if($token!=$formValueHash)

{

echo "Error validating data";

die();

}

// form token and re-created hash equals. Continue doing whatever you wanted

?>

Archived

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

×
×
  • 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.