Easy Session fix I hope

Discussion in 'PHP' started by ppgpilot, Apr 25, 2007.

  1. #1
    I have a script - home_page.php - with a link to - comment.php. visitor hits the link, fills out the form, submits the form to the top of the page via <form action="$_SERVER['PHP_SELF']" method="POST" If all is well the visitor lands on - message_page.php - with a success message.

    It works fine.

    Now, I need to create a session so a person cannot go directly to the -comment.php page without first entering the site through the index.php ~ home_page.php - and if he tries, he is redirected to the index.php page. so far so good.

    So...

    I have a script - index.php - that assigns a $_SESSION variable then sends the visitor to - home_page.php. The - comment.php - page link is still there and both pages - home_page.php and comment.php - have the $_SESSION variable that was created in Index.php.

    Now the problem:

    the visitor fills out the form on the - comment.php - page, this time, however, with sessions - the submit button (with the action="$_SERVER[PHP_SELF]") does not work. Instead, only the page url is sent (file/comment.php) and not the entire URL with host (mysite.com/file/comment.php) causing an error message.

    I can subsitute $_GET instead of $_POST and it works. I can leave off $_SERVER[PHP_SELF]" and just use action="" and it works.


    To make matters worse - It does work on some computers - my Server admin got it to work on everything he tried, and it was verified, but I can't get it to work on anything in the country that I have tried.


    There must be a simple fix but after a week and a half working tirelessly I can't seem to find it.

    David
     
    ppgpilot, Apr 25, 2007 IP
  2. Adam A Flynn

    Adam A Flynn Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hmm, sounds strange. Are you running an up to date version of PHP?
     
    Adam A Flynn, Apr 27, 2007 IP
  3. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Post your code ;)
     
    bobby9101, Apr 27, 2007 IP
  4. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #4
    like bobby said, post your code.

    I don't like humans that much, not enough to read all that text, if it were code I could though .......
     
    krakjoe, Apr 27, 2007 IP
  5. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Store a flag in cookies if flag is set then show the page otherwise redirect to the index page. :)
     
    Subikar, Apr 28, 2007 IP