SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is wrong with this session cache?

    I have the following session cache:

    PHP Code:
    header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
    header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
    header("Cache-Control: post-check=0, pre-check=0",false);
    session_cache_limiter();
    session_start(); 
    Below this cache is a database submission form. And it's doing the following.

    1. When you refresh it removes all the data from the database.
    2. When you press back it removes all the data from the database.
    3. When you leave it logged in overnight it will show page can not displayed and remove all the data from the database.

    When I say it's removing all the data from the database I mean that there is already data submitted in there but it's like it's resetting the form and then submitting it.

    How do I fix this?

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,510
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    post the rest of the code

  3. #3
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

    //prevents caching
    header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
    header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
    header("Cache-Control: post-check=0, pre-check=0",false);
    session_cache_limiter();
    session_start();

    require(
    '/services/webpages/t/i/timesheet.com/public/test/config.php');
    require(
    '/services/webpages/t/i/timesheet.com/public/test/functions.php');

    //check for administrative rights
    if (allow_access(Users) != "yes")
    {
        include (
    '/services/webpages/t/i/timesheet.com/public/test/no_access.html');
        exit;
    }

    ?>


    <?php 
    $db_host 
    "localhost"
    $db_user "lefteh"
    $db_pwd "1234"
    $db_name "MyDB"
    mysql_connect($db_host$db_user$db_pwd); 
    mysql_select_db($db_name); 
    ?> 
    <html> 
    <head> 
    <title>My first MySQL form submission</title> 
    </head> 
    <body> 
    <?php 
    if (!isset($_POST['submit'])) { 
    ?> 
    <form action="" method="post"> 
    Name: <input type="text" name="name"><br> 
    Favorite Color: <input type="text" name="color"><br> 
    <input type="submit" name="submit" value="Submit!"> 
    </form> 
    <?php 
    } else { 
    $name $_POST['name']; 
    $color $_POST['color']; 
    mysql_query("INSERT INTO `colors` (name, favoriteColor) VALUES ('$name', '$color')"); 
    echo 
    "Success! Your favourite colour has been added!"

    ?> 
    </body> 
    </html>

  4. #4
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't see any code that would delete your data from the database.
    Read how session_cache_limiter should be used here
    my mobile portal
    ghiris.ro

  5. #5
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't make sense to me either. I mean there is a reset button and a submit button but those shouldn't be pressed when you press the back button or refresh.

  6. #6
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what would have to be done to make it even do something like this?

  7. #7
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Location
    Virginia
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So your sql query is being run as

    INSERT INTO `colors` (name, favoriteColor) VALUES ('', '')

    or do you mean your database is literally being cleared?
    Mark A. Drake
    - Mark A. Drake
    - OnSlaught

  8. #8
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've located the problem


Bookmarks

Posting Permissions

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