www.webdeveloper.com
Results 1 to 6 of 6

Thread: [RESOLVED] problems with sessions

Hybrid View

  1. #1
    Join Date
    Dec 2011
    Location
    Bucharest Romania
    Posts
    40

    resolved [RESOLVED] problems with sessions

    file1:
    <?php
    if (isset($_POST['submitted'])) {
    session_start();
    echo "happy?";
    echo $_SESSION['info'][$_SESSION['crtnr']];
    }else{
    session_start();
    $_SESSION['crtnr']=1;
    $_SESSION['info'][$_SESSION['crtnr']]='hi there';
    }
    include ('file2.html');
    ?>
    file2:
    <form action='file1.php' method="post">
    <input name="info" value="<?php echo $_SESSION['info'][$_SESSION['crtnr']]; ?>" type="text" size='20'/>
    <input type="hidden" name="submitted" value="1">
    <p><input type="submit" value="Send" /></p>
    </form>

    I thought it would write the session twice, the second time (once in the input box and once out, but it doesn't write it at all.
    I'm in php5.3 by the way.

  2. #2
    Join Date
    Jan 2012
    Posts
    34
    if memory serves me right you must use session_start() at the start of your code right after <?php

  3. #3
    Join Date
    Dec 2011
    Location
    Bucharest Romania
    Posts
    40
    No change.

  4. #4
    Join Date
    Jan 2012
    Posts
    34
    i only quickly looked at it. what exactly are you trying to do. from the look of it your not setting your session variables to be anything at the start

  5. #5
    Join Date
    Dec 2011
    Location
    Bucharest Romania
    Posts
    40
    This is just a simplified example of what's not working.
    These are my two session variables:
    $_SESSION['crtnr']=1;
    $_SESSION['info'][$_SESSION['crtnr']]='hi there';

  6. #6
    Join Date
    Dec 2011
    Location
    Bucharest Romania
    Posts
    40
    I'll explain:
    First i have an input box and a submit button. The input box says 'hi there'.
    I press the submit button and the input box should continue to say 'hi there' and there should also be another 'hi there' But now the 'happy?' is written, but the session is not.
    Which proves that the post worked but the session is lost.
    I tried it on another website I have
    http://papagalii.ro/file1.php - and it works there.
    The webhost company of the site where it doesn't work says that it must work - some answer!
    I found out both sites are 5.2.17 actually.

    OK the problem has been solved. The webhost company explained that until the site is completely moved it will keep doing that.
    Last edited by arrowthesparrow; 10-23-2012 at 02:51 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles