Undesireable sticky form

    Date: 11/25/05 (PHP Community)    Keywords: php, mysql, sql

    This is a first for me and I wonder if anyone else has ran into this problem. The code is really long and consists of several files so I'm not going to list it all. But I'll explain what it does and see if anyone has ever had this problem:

    The "main" page runs a MySQL query. If they've never filled out the form, their data is not in MySQL, therefore the $_SESSION variable will not be set. The code that does this is near the top of the script (after including required files, etc.).

    When the form is filled out and submitted, it calls the same page and also includes another file that processes the form.

    Now with the information submitted and entered into MySQL, it runs back through the "main" page. The code that sets that $_SESSION variable runs a query looking for their entry and then sets the $_SESSION variable to true:

    if ($characters) {
    $_SESSION['characters'] = $characters;
    $_SESSION['character_initialized'] = 1;
    }
    I've tested it with "echo debugs" and it is indeed within the if statement.

    The only way the form is supposed to be shown is if $_SESSION['character_initialized'] is not set. The following calls the form:

    if (!isset($_SESSION['character_initialized'])) {
    include_once ($root_dir . 'content/create_character.php');
    }

    What happens is when the form is submitted, the form comes right back up! But any other click to a link then presents the page the way it's supposed to be. If you try to fill out the form again, it's just going to give back a message that you've already filled out the form.

    So, am I missing something? I might want to add that the $_SESSION variables are within a function. Am I maybe having a variable scope issue? But then, if I am, I would think that the $_SESSION variable would NEVER get set and the second click on the page would just give me back the form again.

    I have never had this problem before and have tried this script literally 30 different ways to find the problem.

    Source: http://www.livejournal.com/community/php/370941.html

« POP3 Webmail PHP Script... || Help :/ »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home