1st Time Trying a Session

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amsterdam
Forum Newbie
Posts: 5
Joined: Sun Mar 16, 2008 8:04 pm

1st Time Trying a Session

Post by amsterdam »

Hi,

I am trying to construct one script with a form that registers sessions with a radio button, a check box and a dropdown select.
I have never used a session before and I am just try to echo out the session values. Any help would be greatly appreciated.
Here is what I have so far. I believe this form is ready to add a session?

Code: Select all

<body><form action="session.php" method="post">Enter Your Name<br/><input type="text" name = "name"><br/>Do you have a purpose here?<br/><input type="checkbox" name="purpose" value="YES" />YES<br />Your Gender?<br/><input type="radio" name = "gender" value="male">Male<br/><input type="radio" name = "gender" value="female">Female<br/>Select your favorite programming language.<br/><select  name="language" >    <option value="">------------</option>    <option value="php">PHP</option>    <option value="javascript">JavaScript</option></select><input type = "submit" value = "Remember Me!"></form>Register your FULL session!</body></html>
Walid
Forum Commoner
Posts: 33
Joined: Mon Mar 17, 2008 8:43 am

Re: 1st Time Trying a Session

Post by Walid »

Where in this script are you trying to echo the session values?
amsterdam
Forum Newbie
Posts: 5
Joined: Sun Mar 16, 2008 8:04 pm

Re: 1st Time Trying a Session

Post by amsterdam »

the bottom
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: 1st Time Trying a Session

Post by andym01480 »

Mmm!

You have an HTML form, now you need to process it and write session variables.

Code: Select all

session_start(); //at the top of every script
$_session['gender']=$_POST['gender'];//etc although you should check the data before writing it to a session variable!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: 1st Time Trying a Session

Post by RobertGonzalez »

You have no session information in that snippet at all. In fact, you don't even have any PHP.
Post Reply