# \[Solved\] Transfer data from one page to another

**URL:** <https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512>\
**Category:** Ask the community\
**Tags:** wix-stores, question, code\
**Created:** [November 26, 2018, 8:29am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512 "2018-11-26T08:29:05Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://forum.wixstudio.com/u/mohamed)\
**Post date:** [November 26, 2018, 8:29am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/1 "2018-11-26T08:29:05Z")

</div>

Hello everyone, I’m trying to create a login page and provide the ability to transfer data from one page to another. In the login page, it will check the database in order to see if the input email and password are the same as email and password stored in the database. After checking that, the input email that is equal to email stored in the database should be transferred into another page (main page). Please find below the code in the login page:

```javascript
// For full API documentation, including code examples, visit http://wix.to/94BuAAs 
import wixData from 'wix-data'; 
import wixUsers from 'wix-users'; 
import wixLocation from 'wix-location'; 
import {session} from 'wix-storage'; 
 
let userEmail; 
let userPassword; 
let user = wixUsers.currentUser;  
$w.onReady(function () 
{ //TODO: write your page related code here...   
$w("#textErrors").hide(); 
})  

export function button1_click(event, $w) 
{ //TODO: write your page related code here..  
let inEmail = $w('#input1');  
let inPassword = $w('#input2');   
let transEmail = inEmail;    
wixData.query("loginDB").eq("email", inEmail).find().then((results) =>   
{  
let resultCount = results.totalCount;    
if (resultCount)     
{       
userEmail = results.items[0].email;       
userPassword = results.items[0].password;   
if (inPassword===userPassword && inEmail===userEmail)       
{           
session.setItem('transEmail', transEmail.value);//Keep in mind, 'item' must be a string. wixLocation.to(`/mainpage`);       
} else {         
$w("#textErrors").show();         
$w("#textErrors").text = "Incorrect email or password.";       
}} else {       
$w("#textErrors").show();       
$w("#textErrors").text = "Can't find the user.";     
}}).catch((err) => 
{  
let errorMsg = err;
});  
return inEmail;
}  

export function button2_click(event) { //Add your code for this event here: }

```

Here is the code in main page:

```javascript
// For full API documentation, including code examples, visit http://wix.to/94BuAAs 
import {session} from 'wix-storage';  

let filteredEmailtxt; 
let filteredEmailvle; 
let filteredEmail;  

$w.onReady(function () 
{ //TODO: write your page related code here...
trans_email();     
console.log(filteredEmail, "here is the email being sent to filter");     
console.log("Dataset is now filtered");  
//$w("#transEmail").hide(); });  

export function button3_click(event) 
{ //Add your code for this event here:      
session.removeItem("inEmail");     
session.clear(); }  

export function trans_email(event, $w) 
{  
const transEmail = session.getItem('transEmail'); //Where result will be a string.     
filteredEmail = transEmail; 
}

```

However, the outcome is: undefined here is the email being sent to filter  
So what did I do wrong here?

#transferdata  
#transferringdatabetweenpages

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 26, 2018, 9:05am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/2 "2018-11-26T09:05:57Z")

</div>

You are not retrieving the values from your input fields. You need to do something like this:

```javascript
let inEmail = $w('#input1').value;  
let inPassword = $w('#input2').value;   
let transEmail = inEmail;    

```

I hope this helps.

---

<div class="post-metadata">

**Author:** ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://forum.wixstudio.com/u/mohamed)\
**Post date:** [November 26, 2018, 9:17am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/3 "2018-11-26T09:17:53Z")

</div>

Dear Yisrael,

I am still getting the same error and I already added the input fields in the login page.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 26, 2018, 9:50am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/4 "2018-11-26T09:50:57Z")

</div>

I just found another error.

You do **not** want this:  
session.setItem(‘transEmail’, **transEmail.value** );//Keep in mind, ‘item’ must be a string.  
You **do** want this:  
session.setItem(‘transEmail’, **transEmail** );//Keep in mind, ‘item’ must be a string.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 26, 2018, 9:54am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/5 "2018-11-26T09:54:35Z")

</div>

BTW - I know that you have the input fields, but you are not retrieving the values correctly.

**not** this:  
let inEmail = $w(’ [#input1](https://www.wix.com/code/home/forum/search/posts%3Fquery=%23input1?forgotPasswordToken=7b2e286cf105bf3de0668f1acc2bf67b81c3fc4ce8dade81b7c03422fee90e4929432b4c1af478dc3797f9d25c0b03e6&lang=en/) ‘);  
this:  
let inEmail = $w(’ [#input1](https://www.wix.com/code/home/forum/search/posts%3Fquery=%23input1?forgotPasswordToken=7b2e286cf105bf3de0668f1acc2bf67b81c3fc4ce8dade81b7c03422fee90e4929432b4c1af478dc3797f9d25c0b03e6&lang=en/) '). **value** ;

---

<div class="post-metadata">

**Author:** ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://forum.wixstudio.com/u/mohamed)\
**Post date:** [November 26, 2018, 9:59am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/6 "2018-11-26T09:59:18Z")

</div>

Dear @yisrael-wix ,

Well, I made the adjustments that you informed me but still it keeps sending to console that its null. Please find below the amended login page:

**import** wixData **from** ‘wix-data’;  
**import** wixUsers **from** ‘wix-users’;  
**import** wixLocation **from** ‘wix-location’;  
**import** {session} **from** ‘wix-storage’;  
**import** {local} **from** ‘wix-storage’;

**let** userEmail;  
**let** userPassword;  
**let** user = wixUsers.currentUser;

$w.onReady( **function** () {  
//TODO: write your page related code here…  
$w(“#textErrors”).hide();  
})

export function button1\_click(event, $w) {  
//TODO: write your page related code here…  
**let** inEmail = $w(‘#input1’);  
**let** inPassword = $w(‘#input2’);

wixData.query(“AttendeeDB”).eq(“email”, inEmail).find().then((results) =\>  
{  
**let** resultCount = results.totalCount;

**if** (resultCount)  
{  
userEmail = results.items[0].email;  
userPassword = results.items[0].password;

**if** (inPassword===userPassword && inEmail===userEmail)  
{  
**let** inEmailtrans = $w(‘#input1’).value;  
**const** transEmail = inEmailtrans;  
console.log(transEmail, “here is the email being sent to filter”);  
local.setItem(‘transEmail’, transEmail);//Keep in mind, ‘item’ must be a string.  
session.setItem(‘transEmail’, transEmail);//Keep in mind, ‘item’ must be a string.

```
    setTimeout(wixLocation.to(`/mainpage?transEmail=inEmail`), 2000) 

```

[//wixLocation.to](https://wixLocation.to)(`/mainpage`);  
} **else** {  
$w(“#textErrors”).show();  
$w(“#textErrors”).text = “Incorrect email or password.”;  
}  
} **else** {  
$w(“#textErrors”).show();  
$w(“#textErrors”).text = “Can’t find the user.”;  
}  
}). **catch** ((err) =\> {  
**let** errorMsg = err;  
});  
**return** inEmail;  
}

and please find below amended main page code:

**import** {session} **from** ‘wix-storage’;  
**import** {local} **from** ‘wix-storage’;  
**import** wixLocation **from** ‘wix-location’;

**let** filteredEmail;  
**let** transEmail;  
**let** inEmail;

$w.onReady( **function** () {  
//TODO: write your page related code here…  
**let** query = wixLocation.query;  
**if** (query.transEmail === inEmail){  
**let** Email = inEmail;  
console.log(Email, “here is the email being sent to filter (location)”);  
}  
Collect\_Email();  
});

export function button3\_click(event) {  
//Add your code for this event here:  
session.removeItem(“inEmail”);  
session.clear();  
}

**function** Collect\_Email()  
{  
**let** transEmailses = session.getItem(‘transEmail’); //Where result will be a string.  
**let** transEmaillcl = local.getItem(‘transEmail’); //Where result will be a string.  
**let** filteredEmailses = transEmailses;  
**let** filteredEmaillcl = transEmaillcl;  
console.log(filteredEmailses, “here is the email being sent to filter (session)”);  
console.log(filteredEmaillcl, “here is the email being sent to filter (local)”);  
console.log(“Dataset is now filtered”);  
}

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 26, 2018, 10:01am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/7 "2018-11-26T10:01:56Z")

</div>

@mohamed You still have the wrong code:

```javascript
let inEmail = $w('#input1');
let inPassword = $w('#input2');

```

You need this instead:

```javascript
let inEmail = $w('#input1').value;
let inPassword = $w('#input2').value;

```

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 26, 2018, 10:06am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/8 "2018-11-26T10:06:58Z")

</div>

You might want to consider using the [wix-users API](https://www.wix.com/code/reference/wix-users.html) to handle your login. This will result in an easier, seamless, more reliable, and more secure login process.

---

<div class="post-metadata">

**Author:** ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://forum.wixstudio.com/u/mohamed)\
**Post date:** [November 26, 2018, 10:11am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/9 "2018-11-26T10:11:36Z")

</div>

I tried using the wix-users API, but, for my site it has different features that I’m afraid that wix-user can not provide. In addition, I used the steps on this question forum and I don’t understand why in his situation it worked. Please find below the link to forum:

> **[SOLVED - wix storage, transferring data between pages | Velo by Wix](https://community.wix.com/velo/forum/coding-with-velo/solved-wix-storage-transferring-data-between-pages)**
>
> Hi,
> 
> I have a little issue that i have been trying to solve, i was wondering if someone might be able to help? What i'm trying to do is get some fields pre-filled from the page they have selected.
> 
> So when they click #bookhere1 this will trigger the...

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 26, 2018, 10:15am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/10 "2018-11-26T10:15:51Z")

</div>

@mohamed You need to make sure to correctly get the values from your input components. For example:  
let inEmail = $w(’ [#input1](https://www.wix.com/code/home/forum/search/posts%3Fquery=%23input1) ').value;  
Did you make the changes?

---

<div class="post-metadata">

**Author:** ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://forum.wixstudio.com/u/mohamed)\
**Post date:** [November 26, 2018, 10:17am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/11 "2018-11-26T10:17:01Z")

</div>

@yisrael-wix , Yes I did. Nothing changed.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 26, 2018, 10:18am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/12 "2018-11-26T10:18:29Z")

</div>

@mohamed Please post the editor URL of your site. _Only authorized Wix personnel can get access to your site in the editor._ Please include the name of the page involved.

---

<div class="post-metadata">

**Author:** ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://forum.wixstudio.com/u/mohamed)\
**Post date:** [November 26, 2018, 10:20am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/13 "2018-11-26T10:20:13Z")

</div>

@yisrael-wix  
Link: [https://editor.wix.com/html/editor/web/renderer/edit/5948205c-05fb-408d-9479-938ed51cf498?metaSiteId=5de86ec1-ff40-450b-96a9-7f8dc19278f7&editorSessionId=f3bdde27-286c-4af8-af2a-4816d419bc7f&referralInfo=dashboard](https://editor.wix.com/html/editor/web/renderer/edit/5948205c-05fb-408d-9479-938ed51cf498?metaSiteId=5de86ec1-ff40-450b-96a9-7f8dc19278f7&editorSessionId=f3bdde27-286c-4af8-af2a-4816d419bc7f&referralInfo=dashboard)

Page: Login and main page.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 26, 2018, 10:35am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/14 "2018-11-26T10:35:01Z")

</div>

@mohamed Your **Log in** button is not connected to the button1\_click() event handler. You can connect it like this:

![](https://us1.discourse-cdn.com/wix/original/3X/0/8/08ebe2ea9d9e5501fff0483eea50f482f1a791b7.png)

---

<div class="post-metadata">

**Author:** ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://forum.wixstudio.com/u/mohamed)\
**Post date:** [November 26, 2018, 10:40am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/15 "2018-11-26T10:40:14Z")

</div>

@yisrael-wix It worked! Thank you very much for your help

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 26, 2018, 10:52am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/16 "2018-11-26T10:52:47Z")

</div>

@mohamed🎉🎉🎉🎉🎉

---

<div class="post-metadata">

**Author:** ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://forum.wixstudio.com/u/mohamed)\
**Post date:** [December 5, 2018, 11:01am UTC](https://forum.wixstudio.com/t/solved-transfer-data-from-one-page-to-another/13512/17 "2018-12-05T11:01:03Z")

</div>

@yisrael-wix would you kindly have a look at my second problem?  
Please find below the link:

> **[Updating record data | Velo by Wix](https://community.wix.com/velo/forum/coding-with-velo/updating-record-data)**
>
> Hello everyone, I'm having a problem in updating a record in the database where a person press the update button and it should update the record. However, all the methods that have been mentioned below does not update the record. What could be the...
