Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11

Thread: Php Session

  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Php Session

    Hi,

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

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

  • #2
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What is the value of the session variable?

  • #3
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also if you could, post the generated HTML source.

  • #4
    New Coder
    Join Date
    Apr 2005
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Looks like it generate more then just a <br/> tag.

    Code:
    <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 />
    ">

  • #5
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #6
    New Coder
    Join Date
    Apr 2005
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It shows 'Array ( )'

  • #7
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you have a session_start(); on the top of this page?

  • #8
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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.

  • #9
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    Quote Originally Posted by cubsfan
    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.

  • #10
    New Coder
    Join Date
    Apr 2005
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    Last edited by ooiyh; 08-31-2006 at 04:52 AM.

  • #11
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    "$question = ( to() ) ? be() : ~be();"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •