View Full Version : Php Session

08-30-2006, 05:22 PM

Anybody know why this code produces a <br/> tag the input textbox?:mad:

<input name="membercode" type="text" id="membercode" value="<?php echo $_SESSION['membercode']; ?>" align="middle"/>

08-30-2006, 05:28 PM
What is the value of the session variable?

08-30-2006, 05:28 PM
Also if you could, post the generated HTML source.

08-30-2006, 06:19 PM
Looks like it generate more then just a <br/> tag.

<input name="membercode" type="text" id="membercode" value="<br />
<b>Notice</b>: Undefined index: membercode in <b>c:\inetpub\wwwroot\cyyamHub\register.php</b> on line <b>37</b><br />

08-30-2006, 06:55 PM
What is the trailing / on the end of your input tag? value="..." />

Looks like the membercode session variable might not be set also. What does print_r($_SESSION); show?

08-30-2006, 07:08 PM
It shows 'Array ( )'

08-30-2006, 07:29 PM
Do you have a session_start(); on the top of this page?

08-30-2006, 08:35 PM
Your session variable doesn't have a value and doesn't exist. If you try to print out a variable that doesn't exist, you will get that notice.

08-30-2006, 09:01 PM
What is the trailing / on the end of your input tag? value="..." />

the trailing slash completes what is known as a 'self-closing tag', and is required in XHTML.

08-31-2006, 03:34 AM
Yes, I did insert the session_start() at the beginning of the page.
But how can I insert a value since my $_Session's value is taken from a redirected page?

Velox Letum
08-31-2006, 04:19 AM
What they are saying is that your value doesn't exist. Undefined index means the index you're using for the $_SESSION superglobal array doesn't exist, and thus the error. Run print_r($_SESSION); and you'll see what I mean.