Algorithm to maintain a blog sign up page

by colin rickels   Last Updated August 08, 2015 21:02 PM

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.



Answers 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?

Alexus
Alexus
July 09, 2015 18:09 PM

Related Questions




Database History Table / Tracking Table

Updated June 26, 2015 17:02 PM


Am I planning my database/backend correctly?

Updated April 08, 2015 18:02 PM