#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    india
    Posts
    6
    Rep Power
    0

    Preventing repetition of a Form


    I have a program [*pseudo code*]:

    if(!isset($_REQUEST["welcome_already_seen"]))
    {
    initialize variables
    }

    $errors_array = array();
    if($_REQUEST["welcome_already_seen"]== "already_seen")
    {
    check_data();
    if(count($errors_array) != 0)
    {
    show_errors();
    show_welcome();
    }
    else
    {
    show_welcome();
    }
    }
    if(!isset($_REQUEST["welcome_already_seen"]))
    show_welcome();

    switch ( $_POST['next_step'] )
    {

    case "step5":
    {
    do something
    form
    next_step = step8;
    /form
    }

    case "step10":
    {
    do something
    form
    next_step = step5;
    /form
    }

    etc...etc
    } //end switch

    function show_welcome()
    {
    do something
    form
    next_step = step10;
    /form
    }

    The show_welcome() persists in each step.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,397
    Rep Power
    594
    1) Enclose your code in [ PHP ] tags. See the sticky at the top of this forum.
    2) Use a session variable.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    india
    Posts
    6
    Rep Power
    0
    do i need some modification in this code?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,397
    Rep Power
    594
    Yes. You need to set up a Session and set a variable to determine if the form has been previously displayed or not. Keep in mind that PHP is stateless. Once it ends it knows nothing about what it may have previously done.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    india
    Posts
    6
    Rep Power
    0
    i have a high regard for your thoughts.

IMN logo majestic logo threadwatch logo seochat tools logo