473,666 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can i assign value returned from javascript function to php session variable

34 New Member
i am stuck in the problem, where after user logs in successfuly, i take him to the login thanks page. now on that page i need to retain the login name. I am not sure how to this.

i have written a query string which passes the SID from this page.

<a href="loginthan ks.php?<?php echo htmlspecialchar s(SID); ?>" >

now how can i send the login name to next page.

Also i want to store this value of login name in some session variable, so that i can display this on everypage user navigates. my problem can also be resolved if i can assign the value returned from javascript function to the a session variable on next page, something like this:

this php code is written in loginthanks.php file
<?php
session_start() ;
$_SESSION['user_logged'] = true;
$_SESSION[loginName] = echo '<script type="text/javascript" getLoginName(); ';
?>
where this function returns the login name.
if this code is syntactically correct then i can this value of session variable?

please help!!

many thanks in advance.
Mar 14 '09 #1
2 7205
abhighat4214
13 New Member
Here are possible answers to your query (I suppose I did undertand your query properly)

1. How can I add login name to $_SESSION : First through your javascript function (which you should define in <head> tag ) use the code
function assignLoginName ()
{

location.href = Add the login name as a query parameter either ? or & depending the other query parameters you pass. This should redirect you to the page that you display after login say succesfull_logi n.php

}

in php
if (isset($_GET['login_name']))
save it in session.
I hope this does solve your query.

I suppose this will also solve your second query, once you have the login_name in session you can pass it to just any page you want. Work it out and reply back

Regards,
Abhijit
Mar 14 '09 #2
rahullko05
34 New Member
i am not sure about how suggested code would work. i have already called a function on click of submit button, after user enters user id & password.
now how would i call another function on its click.

i am pasting the complete code here.

<a href="loginthan ks.php?<?php echo htmlspecialchar s(SID);?>" > <input type="button" name="txt3" id="verifyLogin " value="log in" onclick = "return loginVerificati on()" /></a>

in loginthanks.php i have added the code:

<?php
session_start() ;
$_SESSION['user_logged'] = true;
$_SESSION[loginName] = echo '<script type="text/javascript" getLoginName(); ';
?>

where getLoginName(), returns the loginname entered by user.
Mar 14 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
3219
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone tell me why these DIVs don't drift to the left as they are supposed to? <script language="javascript">
16
25404
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have the properties: mode1, mode2, and mode3. This seems simple but I can't quite figure it out... Any ideas anyone?
2
2186
by: **Developer** | last post by:
I do the following: Note that I'm returning and interface because GetDatObject returns an interface. Public Shared Function GetContents() As DataObject Dim ClipboardDataO As IDataObject = Clipboard.GetDataObject() 'assign an IDataObject reference to a DataObject variable
1
2339
by: bonnie.tangyn | last post by:
Hello all Would it be possible to store javascript document.forms.value to ASP session as global variable? If it is not possible, how can I pass the javascript document.forms.value to ASP/vbscript function? I need to pass the javascript value to ASP/vbscript function because I have to store the javascript value into database. I can't use Request.Form for getting field value. Because there is a
2
2603
by: bonnie.tangyn | last post by:
Hello all Would it be possible to store javascript document.forms.value to ASP session as global variable? If it is not possible, how can I pass the javascript document.forms.value to ASP/vbscript function? I need to pass the javascript value to ASP/vbscript function because I have to store the javascript value into database. I can't use Request.Form for getting field value. Because there is a
2
3401
by: Mirovk | last post by:
Hi, I have a session variable wich value arrives from a previous .asp but in my actual page I need to modify it based upon a selected value from a radio button. I will try to figure out for better understanding: page1.asp ---session("PaymentMethod") page2.asp ---Depending on the radio button selected the payment
4
20019
by: philin007 | last post by:
Hi , I have the following javascript codes: ****************************************** <script language="JavaScript"> <!-- .... ..... if (nextRow >5) {
9
2455
by: stevewy | last post by:
I am trying to write a function that will test all the checkboxes in a particular group of a form (it's a questionnaire), see whether more than three of them are ticked, and display a message if there are. To avoid putting an onClick on each individual checkbox, I am trying to put an onClick in the <TABLEtag that surrounds each question and use srcElement to tell which group has been clicked on and check each checkbox within that group in...
9
2270
by: Marijn | last post by:
Hey everybody, I was wondering if the following would be a valid JavaScript assignment vor a variable and if anybody knows this to work in IE6 or lower? var someVar = (typeof(someVar) === Object) ? this : getVar(); function getVar(){ alert('getVar() called');
0
8352
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6189
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.