# Creating a 6 digit code and using it with text input

**URL:** <https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881>\
**Category:** Questions about Thunkable X\
**Created:** [October 30, 2021, 7:56am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881 "2021-10-30T07:56:00Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmk](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@nmk](https://community.thunkable.com/u/nmk)\
**Post date:** [October 30, 2021, 7:56am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/1 "2021-10-30T07:56:00Z")

</div>

i need help to create a random 6 digit code, that not the same as other codes, users will enter this code in text input and its redirects to a website that the host will choose. i dont want to add so many cloud variables, so im asking here for a better way. if you dont understand, i want to create an app with 6 digit codes like kahoot, but its for a website redirect, not for a quiz.

---

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [October 30, 2021, 8:23am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/2 "2021-10-30T08:23:26Z")

</div>

Hi @nmk

You can create a random 6 digit code like so:

![Screen Shot 2564-10-30 at 15.22.55](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/b/9bb556b4e2f3ce523b49c75e0bd4a0ab855de521.png)

Here is a demo link:

[https://x.thunkable.com/copy/22894c7e1d7fadb571d99f976cfaa3f8](https://x.thunkable.com/copy/22894c7e1d7fadb571d99f976cfaa3f8)

Is this what you are looking for?

Thanks!

---

<div class="post-metadata">

**Author:** ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)\
**Post date:** [October 30, 2021, 8:34am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/3 "2021-10-30T08:34:38Z")

</div>

> [@nmk](#):
>
> that not the same as other codes

You can generate it using @jakeheron advice.  
On the other hand, if you want it to be unique, you need to compare new generate code with other codes already generated. For that you need to keep somehow those codes saved to have a list to compare with. As different users will access and generate codes, you can’t “escape” from keeping that list somehow in cloud.

---

<div class="post-metadata">

**Author:** ![nmk](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@nmk](https://community.thunkable.com/u/nmk)\
**Post date:** [October 30, 2021, 8:49am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/4 "2021-10-30T08:49:37Z")

</div>

i know this code… i am searching for a way that people will not get the same code  
but thanks

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [October 30, 2021, 8:51am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/5 "2021-10-30T08:51:26Z")

</div>

how about this:  
[https://x.thunkable.com/copy/195b0b05c7027b04e06a4093c05db468](https://x.thunkable.com/copy/195b0b05c7027b04e06a4093c05db468)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/7/67140b96a16552344c0d67b975544244c2deabb1.png)

you still need a list of previously generated values to check for preventing duplicates, though

---

<div class="post-metadata">

**Author:** ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)\
**Post date:** [October 30, 2021, 8:52am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/6 "2021-10-30T08:52:38Z")

</div>

> [@nmk](#):
>
> i am searching for a way that people will not get the same code  
> but thanks

Is your app already connected to Firebase or other cloud Database ? Because you need it for that purpose of unique code.

---

<div class="post-metadata">

**Author:** ![nmk](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@nmk](https://community.thunkable.com/u/nmk)\
**Post date:** [October 30, 2021, 8:53am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/7 "2021-10-30T08:53:48Z")

</div>

ty, i will try this

---

<div class="post-metadata">

**Author:** ![nmk](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@nmk](https://community.thunkable.com/u/nmk)\
**Post date:** [October 30, 2021, 8:53am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/8 "2021-10-30T08:53:54Z")

</div>

yes

---

<div class="post-metadata">

**Author:** ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)\
**Post date:** [October 30, 2021, 8:54am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/9 "2021-10-30T08:54:54Z")

</div>

Then you just need a list variable stored in that cloud database.  
After each generated code, add code to list, then before validate next code, just check the list.

---

<div class="post-metadata">

**Author:** ![nmk](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@nmk](https://community.thunkable.com/u/nmk)\
**Post date:** [October 30, 2021, 8:55am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/10 "2021-10-30T08:55:31Z")

</div>

how i can remove it automatically?

---

<div class="post-metadata">

**Author:** ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)\
**Post date:** [October 30, 2021, 8:56am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/11 "2021-10-30T08:56:06Z")

</div>

What will be the moment you won’t need current code anymore ?

---

<div class="post-metadata">

**Author:** ![jakeheron](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jakeheron/32/116818_2.png) [@jakeheron](https://community.thunkable.com/u/jakeheron)\
**Post date:** [October 30, 2021, 9:05am UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/12 "2021-10-30T09:05:04Z")

</div>

> [@nmk](#):
>
> i know this code… i am searching for a way that people will not get the same code  
> but thanks

Sorry for misinterpreting your question. However, next time, you should probably add your code you have made so far so people understand what you have already done. A link to the project would also be helpful.

Thanks!

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:14pm UTC](https://community.thunkable.com/t/creating-a-6-digit-code-and-using-it-with-text-input/1588881/13 "2024-11-08T13:14:34Z")

</div>


