Welcome to Dream.In.Code
Become an Expert!

Join 149,523 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,396 people online right now. Registration is fast and FREE... Join Now!




passing visitor name

 
Reply to this topicStart new topic

passing visitor name

Icecold
4 Jul, 2007 - 11:53 PM
Post #1

New D.I.C Head
*

Joined: 23 Jun, 2007
Posts: 10


My Contributions
How do you pass the name of a visitor to your website from one page to another so the page visited will contain a welcome msg with their name at the top of the page?
User is offlineProfile CardPM
+Quote Post

1lacca
RE: Passing Visitor Name
5 Jul, 2007 - 12:09 AM
Post #2

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
You should look for the term: session.
Generally if you want to store information about a user while he is browsing your site, you must create a session. You can store it on the server, at the client in cookies, or you might propagate all the information in the url (as get attributes).
Storing at the server needs serverside scripting, anything from php, asp, jsp, you name it should work.
Using cookies is easier, you can get away without using serverside scripting, but they can be disabled, and then your site won't work.
Finally propagating in the url is cumbersome (you must use javascript to generate all the links or requests so taht you can put the info into it dynamically), and the quantity of information that you can store this was is very limited.
Bottomline: try one of the serverside technologies (PHP is free and easy to learn, and most web hosting companies have it), all of them provide session management that is usually easy to use.
User is offlineProfile CardPM
+Quote Post

Icecold
RE: Passing Visitor Name
5 Jul, 2007 - 03:12 AM
Post #3

New D.I.C Head
*

Joined: 23 Jun, 2007
Posts: 10


My Contributions
I have a form that I will have the user input his name into, what would the code look like using PHP?
User is offlineProfile CardPM
+Quote Post

capty99
RE: Passing Visitor Name
5 Jul, 2007 - 06:04 AM
Post #4

the real kya
Group Icon

Joined: 26 Apr, 2001
Posts: 9,252



Thanked: 16 times
Dream Kudos: 550
My Contributions
just google php sessions ,
if you take a look at that and don't understand part of it,
or have trouble getting it to work feel free to ask,
but this site is more about helping with a problem,
we don't really like writing up code and just handing it off.

welcome to the site though, and not being rude just letting you know.
User is offlineProfile CardPM
+Quote Post

1lacca
RE: Passing Visitor Name
5 Jul, 2007 - 06:08 AM
Post #5

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
This last question should be asked in the PHP forum.
Also, please read the forum rules, because you are not likely to get any answers for a question like this.
Finally, there are some PHP samples in the snippets section, soem of them dealing with forms. Also, try searching for php session tutorial in google, and I am sure you will find something that you could even copy&paste into your project...

and TJL beat me on this one...
User is offlineProfile CardPM
+Quote Post

Welli
RE: Passing Visitor Name
5 Jul, 2007 - 01:47 PM
Post #6

New D.I.C Head
*

Joined: 5 Jul, 2007
Posts: 28


My Contributions
I'm too nice.

Assuming you have an HTML form with a text box named 'name' and you're using POST for simplicity, the below will work. If you don't understand POST/GET I'm not going to help you.

CODE

<?php
session_start();
$_SESSION['name'] = $_POST['name'];
?>


On all subsequent pages where you want the name to appear you can reference it with $_SESSION['name'].

You could also use cookies.

This post has been edited by Welli: 5 Jul, 2007 - 01:48 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 08:34PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month