# Need help - Search if email already exists in Database

**URL:** <https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791>\
**Category:** Database\
**Created:** [November 11, 2021, 10:43am UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791 "2021-11-11T10:43:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![evate](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/evate/32/111882_2.png) [@evate](https://forum.bubble.io/u/evate)\
**Post date:** [November 11, 2021, 10:43am UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/1 "2021-11-11T10:43:38Z")

</div>

Hi all,

Pretty new here, but loving Bubble already! Just running into a small thing that I think should be super easy to solve, but I just cannot make it seem to work.

I’m combining the sign up and log in into one page.

 ![Screenshot 2021-11-11 at 11.36.56](https://us1.discourse-cdn.com/bubble/original/3X/0/d/0d41520cde05f95e392a691a7e5ed793610dc96f.png)

The conditional logic I’m trying to aim for is the following:  
When the “Continue” button is clicked \> Do a search in the database if the email entered in the email input exists already.  
If not → Sign the user up with the credentials entered  
If already exists → Log the user in.

I Googled, tried, but cannot seem to make it work.

 ![Screenshot 2021-11-11 at 11.38.36](https://us1.discourse-cdn.com/bubble/original/3X/c/7/c7625a7fdbcb8cb08771722f5dad01790e461798.png)

It will always return “True” in the above example. I hoped with the above formula it would return “False” if the email already exists in the database. But unfortunately, when I enter an email that already exists in the user database, it will still return true and try to sign the user up.

(Please note that once I’ve got the sign up workflow working I will create the opposite one for the Log In, I understand these should be two separate workflows).

Could someone be so kind and give me an explanation on what I am doing wrong here and how I can ensure my formula works?

Would be greatly appreciated, thank you! 🙂

Update: also tried the below, but **it looks like the “Search For User’s email” does not return anything** , see the debugger information below.

 ![Screenshot 2021-11-11 at 12.09.31](https://us1.discourse-cdn.com/bubble/original/3X/5/3/537844b1fff19bee07e78dece28a1ae6f6d16e15.png)  
 ![Screenshot 2021-11-11 at 12.11.39](https://us1.discourse-cdn.com/bubble/original/3X/1/8/189e32f60a75870964a819f96f4053d4b1e2bbd1.png)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [November 11, 2021, 11:22am UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/2 "2021-11-11T11:22:05Z")

</div>

you need to search for User’s who’s email matches the Email Input’s value.

So do a search for Users, with the constraint:  
Email=Email Input’s Value

Then do the count of returned results on that (i.e. is 0, or \>0 etc.)

---

<div class="post-metadata">

**Author:** ![evate](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/evate/32/111882_2.png) [@evate](https://forum.bubble.io/u/evate)\
**Post date:** [November 11, 2021, 11:24am UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/4 "2021-11-11T11:24:30Z")

</div>

Thank you for replying and helping me.

I’ve tried that exactly. But unfortunately the ‘count = 0’ always is true, because the Search for Users for some reason doesn’t return **any** results.

I did a “Search for Locations” (another database field), and that actually returns the data immediately. For some reason “Search of Users” doesn’t. I am confused to why. I’ve checked, but there is definitely data in the database.

![Screenshot 2021-11-11 at 12.25.05](https://us1.discourse-cdn.com/bubble/original/3X/b/3/b3673de0248f1fbb88a6c5a28bf185a041ced16d.png)

 ![Screenshot 2021-11-11 at 12.26.04](https://us1.discourse-cdn.com/bubble/original/3X/c/d/cd6c8f45cdd1b3780b61e9a8ebf8e68ec000d053.png)

Could this be due to privacy settings?

 ![Screenshot 2021-11-11 at 12.30.29](https://us1.discourse-cdn.com/bubble/original/3X/b/f/bfb84c43dfcf8b114dbd46984267d8644b893210.png)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [November 11, 2021, 11:47am UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/5 "2021-11-11T11:47:13Z")

</div>

> [@evate](#):
>
> Could this be due to privacy settings?

Yes, it could well be.

---

<div class="post-metadata">

**Author:** ![evate](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/evate/32/111882_2.png) [@evate](https://forum.bubble.io/u/evate)\
**Post date:** [November 11, 2021, 12:57pm UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/6 "2021-11-11T12:57:49Z")

</div>

**"Solved" the issue:**

The functions I tried didn’t work because Search for Users didn’t return any data due to privacy settings. This can be solved by setting the User’s Email to public - which I do not want due to privacy.

So am going to look for an alternative solution, right now I’m thinking about separating login and sign up after all, but let’s see.

If anybody has a good idea for me to solve this, which is still good for privacy reasons, please do let me know.

---

<div class="post-metadata">

**Author:** ![jared.gibb](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jared.gibb/32/123329_2.png) [@jared.gibb](https://forum.bubble.io/u/jared.gibb)\
**Post date:** [November 11, 2021, 1:40pm UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/7 "2021-11-11T13:40:59Z")

</div>

Although it might not be the most efficient process, you could offload the search for email comparison to the backend. When it’s part of a back and workflow you can check the box to ignore privacy settings. This ensures that no outsiders get access to your users data but also allows your app to check if an email already exist without exposing any information to any other user that’s not requested as part of the query

---

<div class="post-metadata">

**Author:** ![ThatFizzGuy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/thatfizzguy/32/134386_2.png) [@ThatFizzGuy](https://forum.bubble.io/u/ThatFizzGuy)\
**Post date:** [July 13, 2022, 12:27pm UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/8 "2022-07-13T12:27:49Z")

</div>

@jared.gibb I’d love to learn more about your suggestion here. If the backend workflow ignores privacy settings, how is this still considered secure?

What are others doing to check if an email already exists, while still keeping email hidden behind a privacy rule? Thanks!

---

<div class="post-metadata">

**Author:** ![ThatFizzGuy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/thatfizzguy/32/134386_2.png) [@ThatFizzGuy](https://forum.bubble.io/u/ThatFizzGuy)\
**Post date:** [July 13, 2022, 12:29pm UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/9 "2022-07-13T12:29:01Z")

</div>

@evate did you ever come up with a better solution here? just curious, thanks!

---

<div class="post-metadata">

**Author:** ![petrosdias](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@petrosdias](https://forum.bubble.io/u/petrosdias)\
**Post date:** [January 6, 2023, 8:28pm UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/10 "2023-01-06T20:28:34Z")

</div>

Also having the same problem. My implementation has to do with sms OTP but similar scenario. Any ideas?

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [January 6, 2023, 8:31pm UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/11 "2023-01-06T20:31:09Z")

</div>

What is the problem?

---

<div class="post-metadata">

**Author:** ![keith](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/keith/32/56020_2.png) [@keith](https://forum.bubble.io/u/keith)\
**Post date:** [January 6, 2023, 9:35pm UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/12 "2023-01-06T21:35:03Z")

</div>

It should also be noted (@petrosdias): There is no need to do this (“search if email already exists in database”). Bubble does that natively. User emails must be unique and signup will fail if the email already exists.

I should also note: This is [well documented](https://manual.bubble.io/core-resources/actions/account#sign-the-user-up).

---

<div class="post-metadata">

**Author:** ![petrosdias](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@petrosdias](https://forum.bubble.io/u/petrosdias)\
**Post date:** [January 7, 2023, 9:57pm UTC](https://forum.bubble.io/t/need-help-search-if-email-already-exists-in-database/177791/13 "2023-01-07T21:57:36Z")

</div>

My implementation was a little bit more specific. I needed to sign-up a user but also generate an OTP which is assigned as a password. I ended up managing to do that with the built-in functionality and error code of USED\_EMAIL.  
The trick was creating a backend workflow which generates the OTP which can then be used as a password and in other places.
