close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

how do I generate a 5 digit random number per order

Thread began 4/30/2010 4:15 am by eyoung296270 | Last modified 5/13/2014 4:38 pm by anonymous | 15676 views | 9 replies |

eyoung296270

how do I generate a 5 digit random number per order

I have a ecart 5 site set up that sells online tests where clients login pay for a test and when successfully passing gets a certificate. I have been asked to have the purchases generate a 5 digit code per test so that only one person can take a test based on the 5 digit code.
How would I do that?

Sign in to reply to this post

Jason ByrnesWebAssist

Security assist includes a random password generator that could be used to accomplish this.

With security assist installed, go to the bindings panel. Click the plus button, and select Security Assist -> Random Password.

in your cart, you will need to create a new column to hold the random number this column should be set to be unique.


In the add to cart button, select the new cart column, click the lightning bolt next to the random number column and select the Random Password binding from the binding panel.

Sign in to reply to this post

eyoung296270

Thanks Jason,
I have purchased the security assist and set it up based on your input. I am drawing a blank on how to make it so that I can use that random 5 digit code as a measure to insure that only the purchaser can take the test. Any help on a solution would be appreciated.
Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

you would need to create another table in your database to link the random number to the test:

testKeyID - Primary Key, Auto Number
testKey - the random number will be stored in this column
testID - Foreign Key relation to relate the testKey to the test.

when they purchase the key should be stored in this new table along with the ID the key is for.

On the first page of the test, they should enter the test key. create a recordset that filters the testKey table to see if it is a valid key for that test and only allow them to procede if it is found.

Sign in to reply to this post

eyoung296270

storing random key

Thanks Jason. I follow everything but I am at a lost as to how to do this: when they purchase the key should be stored in this new table along with the ID the key is for.
Does I do this at the confirm page and how do I store the information into the key table. All I see that I can work with via the checkout wizard is the orders and orderdetails table.

Sign in to reply to this post

Jason ByrnesWebAssist

you wont be able to store the key using the checkout wizard, you need to add an insert record server behavior to the confirm page after running the checkout wizard.


to be honest, this is not a standard use of eCart and can be confusing and difficult to implement if you are not comfortable with PHP and MySQL. Really all I can offer is a general overview of how to accomplish this, not specific steps.

If you are not comfortable with PHP and MySQL, I would suggest posting for assistance in the Job Board.

Sign in to reply to this post

eyoung296270

random id isn't posting

Hi Jason,
Thanks for your help. I am able to get the test Id to post to the new testkey table but not the random code to post to the table using the insert server behavior.
This is what I did...please let me know where I am falling short:
I added a new testkey column to ecart and set it to be unique I named it DetailRandom.
Then on the products page I added the add to cart button, selected the new DetailRandom cart column, clicked the lightning bolt next to the random number column and selected the Random Password binding from the binding panel.
I then added a new table to my database with the columns
testkeyID - Primary key Auto Number
testKey - the random number will be stored in this column
ItemIDfk - Foreign Key relation to relate the testKey to the test
I then added hidden form variables for the ItemID and the testKeyID to the checkout page.
I binded the ItemID with the ecart ItemId variable <?php echo $eCart1->DisplayInfo("ID"); ?> to the checkout page and I binded the testKey that was generated with the Security Assist with the ecart testKey <?php echo $eCart1->DisplayInfo("DetailRandom"); ?> to the checkout page.
I then added the Insert Server Behavior to the confirm page and using the checkout form I selected the new table (testkey) and I selected the DetailRandom field in the checkout form page for the testkey value and I selected the ItemId field for the ItemIDfk field.
When I ran a purchase everything went fine for the purchase but the only fields added to the testKey table was the ItemId field from the testproducts Id. The Detail Random field in the ecart object was not added.
The detailrandom key worked in this table until I tried to add the insert record server behavior with both fields.
What am I doing wrong?

Sign in to reply to this post

eyoung296270

it worked

Hi Jason,
I deleted the random password and all references. I changed all references to match the name of the field in the new table and reapplied the insert server behavior and all is working now.
Thanks again

Sign in to reply to this post

this_is_me

this is easy in php

<?php
srand ((double) microtime() * 1000000);
$random5 = rand(10000,99999);
echo $random5;
?>

Sign in to reply to this post

anonymous

Am Greatful

Must say that this post has salvage me of a long unrealistic task. I have been sourcing for a php code to generate a random number and I have just achieved it fews minutes ago.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...