0

I have a functional sign up page for a blog that updates a database with a users name, email, profile picture and a short bio. The General information page and the profile picture upload/bio page are two separate pages and I have a problem with users being able to go back into their profile pic page and re-entering their information again for their bio and user which then screws the entire database up. While incorporating php $_SESSION, I want to be able to track a users progress with the form and if attempting to update the same form page, have the user sent to their current page that has yet to be completed. I'm in search of an algorithm suitable for this and yet have not been able to implement one that works properly. The first page of my form looks to see if step01(general info form) has been completed.

    session_start();
if(!isset($_SESSION['step01']))
{
    if($_SESSION['step01']=='complete')
    {
        echo "<script>window.location.assign('localhost:8888/knoxville_programmers/blog-signup-propic.php');</script>";
    }
    else
    {
        $_SESSION['step01'] ='incomplete';
    }
}

Upon completion of the first form the second form for uploading a user picture and bio checks if 1.) the first form is completed and 2.) that the current form hasn't already been completed. If it has then the user is redirected to their user page.

    session_start();
if(!$_SESSION['step01']=='complete')
{
    echo "<script>window.location.assign('localhost:8888/knoxville_programmers/blog-signup.php');</script>";
    #echo "<script>window.location.assign('localhost/knoxville_programmers/blog-signup.php');</script>";
}
elseif($_SESSION['step01']=='complete')
{
    if(!isset($_SESSION['step02']))
    {
        $_SESSION['step02']='incomplete';
    }
    elseif (isset($_SESSION['step02'])) 
    {
        if($_SESSION['step02']=='complete')
        {
            echo "<script>window.location.assign('localhost:8888/knoxville_programmers/user-page.php');</script>";
            #echo "<script>window.location.assign('localhost/knoxville_programmers/user-page.php');</script>";
        }
        else
        {
            $_SESSION['step02']='incomplete';
        }
    }

}

My method of approach is error prone and i have not been able to have it work properly for a minute and am in need of a more suitable idea.

1

I would look at reworking the way you save your data. Profile can exist without picture, while picture can't exist without profile.

So, once people are done with their profile, save it. Once they are done with picture, save it separately. Why separate the registration into a number of pages, if you don't save the data independently?

  • i guess i split the registration into seperate pages for user readability purposes. When starting the site i wanted it not to appear as a long listed sign up but an interactive sign-up that says hey this site had some creative ideas thrown around. But your actually right it would be far more suitable to have the user create the profile registration of basic information and then give them the option to upload a profile picture whenever they want. – colin rickels Jul 13 '15 at 5:54
  • Yep, and if you keep the data independent - hence they can add info at any given moment, you will greatly improve your user experience. – Alexus Jul 13 '15 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.